Stata Do File If Statement. Using this command incorrectly results in the evaluation of the expression using only the first observation of the variable. This module shows the use of if with common stata commands.
The if command suffix is used to restrict on which data a command is run. In stata the equivalent of your nesting example would be in addition to the statements above. Replace var2 y if cond7 the if qualifier cannot be nested in the same way as sas.
To run this do file simply click in windows on filename carsdata do this file needs to be in the same directory as file carsdata dta alternatively start stata give command cd c stata if file carsdata do and carsdatat dta are in directory c stata.
To run this do file simply click in windows on filename carsdata do this file needs to be in the same directory as file carsdata dta alternatively start stata give command cd c stata if file carsdata do and carsdatat dta are in directory c stata. If you are new to stata we strongly recommend reading all the articles in the stata basics section. A command can only have one if statement but multiple parameters can be specified using the for example say i wanted to summarize gpa for a data set. Let s use the auto data file.
