Hello everybody.
I am trying to find a way to divide variables in a sequenced/ordered way.
I have to divide limit variables and income variables per country.
I tried 3 different commands but none of them worked properly.
1.Command: Don't create any new variable.
foreach var of varlist incomeusa-incomefrance {
foreach y of varlist limitusa-limitfrance {
generate `var'dif = `y' / `var'
}
}
incomeusadif already defined
r(110);
end of do-file
2. Command: Create variables but all income variables are using just limitusa as numerator
foreach var of varlist incomeusa-incomefrance {
foreach y of varlist limitusa-limitfrance {
generate `y'dif = `y' / `var'
}
}
limitusadif already defined
r(110);
end of do-file
3. Command: Tried to use the collon before the divison signal, but didnt worked either.
foreach var of varlist incomeusa-incomefrance {
foreach y of varlist limitusa-limitfrance {
generate `y'dif = `y' :/ `var'
}
}
limitusa: invalid name
r(198);
end of do-file
Anyone has an idea how to perfom division between variables in a sequenced way?
Thank you,
Ricardo.
I am trying to find a way to divide variables in a sequenced/ordered way.
incomeusa | incomechina | incomecanada | incomefrance | limitusa | limitchina | limitcanada | limitfrance |
6000 | 1265 | 3776 | 0 | 15 | 23 | 2 | 13 |
4356 | 6785 | 3577 | 10089 | 18 | 4 | 34 | 11 |
7643 | 4456 | 1322 | 678 | 9 | 5 | 5 | 24 |
1087 | 365 | 0 | 778 | 8 | 8 | 14 | 11 |
4456 | 44 | 5789 | 676 | 6 | 6 | 17 | 1 |
I tried 3 different commands but none of them worked properly.
1.Command: Don't create any new variable.
foreach var of varlist incomeusa-incomefrance {
foreach y of varlist limitusa-limitfrance {
generate `var'dif = `y' / `var'
}
}
incomeusadif already defined
r(110);
end of do-file
2. Command: Create variables but all income variables are using just limitusa as numerator
foreach var of varlist incomeusa-incomefrance {
foreach y of varlist limitusa-limitfrance {
generate `y'dif = `y' / `var'
}
}
limitusadif already defined
r(110);
end of do-file
3. Command: Tried to use the collon before the divison signal, but didnt worked either.
foreach var of varlist incomeusa-incomefrance {
foreach y of varlist limitusa-limitfrance {
generate `y'dif = `y' :/ `var'
}
}
limitusa: invalid name
r(198);
end of do-file
Anyone has an idea how to perfom division between variables in a sequenced way?
Thank you,
Ricardo.
Comment