Basically, there are some syntax issues to be addressed. You can reach
your objective by using one of the two following command:
gen time1 = time if code == 1 | code == 2
(pay attention to "|" character)
or you can use a two-step command:
gen time1 = time if code == 1
replace time1 = time if code == 2
Cheers.
Domenico
2008/10/15, Beatrice Crozza <[email protected]>:
> Dear all,
>
> maybe this is a simple question, but I don't know how to overcome my
> problem.
>
> I have a variable time and I should generate another variables equal
> to time when another variable (code) is equal to 1 or 2.
>
> However, I don't know how to instruct stata for this.
>
> I tried with:
> gen time1= time if code==1 & code==2
>
> but of course I will have all missing values.
>
> Thus, I created two variables:
> gen time1= time if code==1
> gen time1= time if code==2
>
> but I would like to merge the values of the two variables at this point.
>
> Any idea of how to do this?
>
> Thank you.
>
> Best,
> Bea
> *
> * 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/