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: How can I loop this?
From
Adam Guerrero <[email protected]>
To
[email protected]
Subject
Re: st: How can I loop this?
Date
Sat, 4 May 2013 16:45:48 -0400
Hi Nick,
Awesome. Thank you so much for your reply...reading all FAQs now! :-)
ag
On Sat, May 4, 2013 at 4:32 PM, Nick Cox <[email protected]> wrote:
> No need to loop.
>
> Your question is an FAQ.
>
> http://www.stata.com/support/faqs/data-management/replacing-missing-values/
>
> Nick
> [email protected]
>
>
> On 4 May 2013 21:23, Adam Guerrero <[email protected]> wrote:
>> Hi Stata Users,
>>
>> I have an unbalanced panel comprised of student years which can be
>> reshaped into student terms (six years, three terms per year,
>> providing a maximum 18 observations per student). One of the
>> variables included in the data is a student's major area of
>> specialization - major1.
>>
>> For some students this variable is defined at the start of their
>> educations, missing for a few years, then defined again. After
>> consulting with the registrar at the institution under analysis the
>> following code was used to fill in the gaps
>>
>> by id: replace major1=major1[_n+1] if major1=="" & major1[_n+1]!="" & _n!=_N
>> by id: replace major1=major1[_n+1] if major1=="" & major1[_n+1]!="" & _n!=_N
>> by id: replace major1=major1[_n+1] if major1=="" & major1[_n+1]!="" & _n!=_N
>> by id: replace major1=major1[_n+1] if major1=="" & major1[_n+1]!="" & _n!=_N
>> by id: replace major1=major1[_n+1] if major1=="" & major1[_n+1]!="" & _n!=_N
>>
>> In other words, I had to type the same line of code over and over
>> until all of the values were replaced. My question is whether there
>> is a more efficient way to do this? I'm relatively new to Stata, so
>> any advice would be very much appreciated.
>>
>> Adam Antonio
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
--
Adam A. Guerrero
Skype: adamadam3741
Phone: 214-274-3776
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/