Hi,
I am new in stata and want to generate several new variables, some of them
under the same conditionals, something like this:
gen var1= varold01 if ( nivel=1 & area=1 & sex=1)
gen var2=varold02 if ( nivel=1 & area=1 & sex=2)
gen var3= varold03 if ( nivel=1 & area=2 & sex=1)
gen var2=varold02 if ( nivel=1 & area=2 & sex=2)
gen var4= varold04 if ( nivel=1 & area=1 )
gen var5=varold05 if ( nivel=1 & area=2 )
I want to know if stata has a command that let me do something like this:
if nivel=1 & area=1 then do;
gen var2=varold02 if (sex=2)
gen var4= varold04
if nivel=1 and area=2 then do;
gen var3= varold03 if ( sex=1)
gen var2=varold02 if ( sex=2)
gen var5=varold05
that let me reduce the number of conditionals