I wrote a program for repetitive but simple work using foreach. But it didn't work.
For a variable of fc1, I recoded the variable, creating a new variable of r_fc1 as belows:
recode fc1 (1=100)(2=75)(3=50)(4=25)(5=0), gen(r_fc1)
But I wanted to make it simple because I should do that for fc2...fc5. So I wrote as belows:
foreach N of numlist 2/5 {
recode fc'N' (1=100)(2=75)(3=50)(4=25)(5=0), gen(r_fc'N')
}
But it resulted in the following:
fc ambiguous abbreviation
r(111);
What is wrong with it?
I would like to do the same thing to the variables of comp1...comp4, coord1...coord3.
Can you give some advices on a right, smarter programming?
For a variable of fc1, I recoded the variable, creating a new variable of r_fc1 as belows:
recode fc1 (1=100)(2=75)(3=50)(4=25)(5=0), gen(r_fc1)
But I wanted to make it simple because I should do that for fc2...fc5. So I wrote as belows:
foreach N of numlist 2/5 {
recode fc'N' (1=100)(2=75)(3=50)(4=25)(5=0), gen(r_fc'N')
}
But it resulted in the following:
fc ambiguous abbreviation
r(111);
What is wrong with it?
I would like to do the same thing to the variables of comp1...comp4, coord1...coord3.
Can you give some advices on a right, smarter programming?
Comment