Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: A coding question


From   Adam Olszewski <[email protected]>
To   [email protected]
Subject   Re: st: A coding question
Date   Wed, 28 Mar 2012 12:53:14 -0400

or just:
replace var1=1 if year=="07"
(assuming year is a string for some reason)


On Wed, Mar 28, 2012 at 12:41 PM, Joerg Luedicke
<[email protected]> wrote:
> I would create a new variable (preserving original information):
>
> egen var2=max(var1), by(year)
>
> J.
>
> On Wed, Mar 28, 2012 at 9:32 AM, Rituparna Basu <[email protected]> wrote:
>> Dear STATAlist,
>>
>> I have a variable which looks like:
>> var 1  year
>> 1      07
>> .      07
>> .      07
>> 1      07
>> .      08
>> .      08
>> .      08
>>
>> But I want to make it look like this:
>>
>> var 1  year
>> 1      07
>> 1      07
>> 1      07
>> 1      07
>> .      08
>> .      08
>> .      08
>>
>>
>> Could you suggest how to do it? I have tried different ways but does not seem to work.
>>
>> Thank you in advance!
>>
>> Regards,
>>
>> RB
>>
>>
>> *
>> *   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/

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index