Dear StataList,
I have a fairly simply task that I'd appreciate help with. I'm trying to write a block of code that will work on a number of different datasets. I'd like the code to put the variables in a certain order. The issue is that in some of the datasets one or more of the variables is missing. A similar question was asked before but I haven't been able to modify the solution properly. This is the code that I'm using.
sysuse auto
local vars "foreign gear_ratio missing"
foreach var in `vars'{
capture confirm variable `vars'
if !_rc {
order `vars'
}
}
The code only works if all the variables are in the dataset. I'm using Stata 11.
Thanks for your help,
Wilfred
I have a fairly simply task that I'd appreciate help with. I'm trying to write a block of code that will work on a number of different datasets. I'd like the code to put the variables in a certain order. The issue is that in some of the datasets one or more of the variables is missing. A similar question was asked before but I haven't been able to modify the solution properly. This is the code that I'm using.
sysuse auto
local vars "foreign gear_ratio missing"
foreach var in `vars'{
capture confirm variable `vars'
if !_rc {
order `vars'
}
}
The code only works if all the variables are in the dataset. I'm using Stata 11.
Thanks for your help,
Wilfred