Hello everybody,
I have a problem and was not able to find a solution for this.
I want to do a loop including an if function looking like this:
foreach var of varlist BTMCH* {
xtile E`var' = `var' if SMVJ*==1, nq(5)
xtile E`var' = `var' if SMVJ*==2, nq(5)
xtile E`var' = `var' if SMVJ*==3, nq(5)
xtile E`var' = `var' if SMVJ*==4, nq(5)
xtile E`var' = `var' if SMVJ*==5, nq(5)
}
I have BTMCH2002 BTMCH2003,..., BTMCH2013 and also SMVJ2002,...,SMVJ2013
So I want to create new variables called EBTMCH* for BTMCH2002 if SMVJ2002 = 1, for SMVJ2002=2,... and then also for BTMCH2003 if SMVJ2003=1, for SMVJ2003=2,... until BTMCH2013 if SMVJ2013=1, for SMVJ2013=2,...
The error message is: SMVJ* is an invalid name. So the problem is how to define SMVJ* differently to be able to execute the program.
Can you help me with this please.
Thanks a lot for your help
Best Max
I have a problem and was not able to find a solution for this.
I want to do a loop including an if function looking like this:
foreach var of varlist BTMCH* {
xtile E`var' = `var' if SMVJ*==1, nq(5)
xtile E`var' = `var' if SMVJ*==2, nq(5)
xtile E`var' = `var' if SMVJ*==3, nq(5)
xtile E`var' = `var' if SMVJ*==4, nq(5)
xtile E`var' = `var' if SMVJ*==5, nq(5)
}
I have BTMCH2002 BTMCH2003,..., BTMCH2013 and also SMVJ2002,...,SMVJ2013
So I want to create new variables called EBTMCH* for BTMCH2002 if SMVJ2002 = 1, for SMVJ2002=2,... and then also for BTMCH2003 if SMVJ2003=1, for SMVJ2003=2,... until BTMCH2013 if SMVJ2013=1, for SMVJ2013=2,...
The error message is: SMVJ* is an invalid name. So the problem is how to define SMVJ* differently to be able to execute the program.
Can you help me with this please.
Thanks a lot for your help
Best Max
Comment