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: create a variable using the first value in time-series data by group


From   PKCHEN UMD <[email protected]>
To   [email protected]
Subject   Re: st: create a variable using the first value in time-series data by group
Date   Tue, 11 Jun 2013 00:52:17 -0400

Thank you! It works! I didn't know it was so easy

2013/6/11 PingKuei Chen <[email protected]>:
> Thank you very much! This totally works. I didn't know it was so easy.
>
> 2013/6/10 Sergiy Radyakin <[email protected]>:
>> Once you have the first value figured out, something like this would
>> populate the rest:
>>
>> clear
>> input id year x
>> 1 2000 0.7
>> 1 2001 .
>> 1 2002 .
>> 1 2003 .
>> 2 2000 0.9
>> 2 2001 .
>> 2 2002 .
>> 2 2003 .
>> end
>> bysort id (year): replace x=x[1]
>> list, sepby(id)
>>
>>      +----------------+
>>      | id   year    x |
>>      |----------------|
>>   1. |  1   2000   .7 |
>>   2. |  1   2001   .7 |
>>   3. |  1   2002   .7 |
>>   4. |  1   2003   .7 |
>>      |----------------|
>>   5. |  2   2000   .9 |
>>   6. |  2   2001   .9 |
>>   7. |  2   2002   .9 |
>>   8. |  2   2003   .9 |
>>      +----------------+
>>
>>
>> Sergiy
>>
>> On Mon, Jun 10, 2013 at 9:33 PM, PKCHEN UMD <[email protected]> wrote:
>>> Hello Statalist,
>>> I have a time-series cross sections dyad-year dataset. I run the
>>> regression and create the prediction variable for each observation. I
>>> want to take the prediction of the first year of each dyad and times
>>> 1.3. There is one number for the beginning year of every dyad. Then I
>>> want to compare the rest of years of prediction with the beginning
>>> year. My goal is to create a dummy variable that is 1 if any yearly
>>> prediction for that dayd is more than 1.3*the beginning year
>>> prediction.
>>>
>>> I manage to create a variable that contains the 1.3*the first year
>>> prediction using by dyad: gen. But I can only tell stata to fill in
>>> the value of the beginning. The rest of yearly observations are coded
>>> as missing. Is there a command that can autofill the missing value
>>> with the first year prediction I create? Or is there a more succinct
>>> way to create the dummy variable I want?
>>>
>>> Thank you very much!
>>>
>>> --
>>> Ping-Kuei Chen
>>> *
>>> *   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/
>
>
>
> --
> Ping-Kuei Chen
*
*   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/


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