gen b =.
replace b=1 if a1==1
replace b=2 if a2==3
replace b=3 if a3==8
On May 20, 2009, at 1:56 PM, Charles Man@CCR wrote:
Dear Statalisters,
If I want to create a new variable based on the values of a few
other variables, how can I do that?
For instance,
Create B
If A1=1, then B=1
If A2=3, then B=2
If A3=8, then B=3
Can -gen- or -egen- or -recode- do this job?
Thanks,
Charles
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/