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: Generating variable in panel dataset
From
Shikha Sinha <[email protected]>
To
[email protected]
Subject
Re: st: Generating variable in panel dataset
Date
Tue, 28 Dec 2010 19:36:06 -0500
Hi Sergiy,
,
I want to code A,B,C in 2008 as low=1 because their value was 1 in 2002.
Thanks,
Shikha
On Tue, Dec 28, 2010 at 7:28 PM, Sergiy Radyakin <[email protected]> wrote:
> On Tue, Dec 28, 2010 at 6:57 PM, Shikha Sinha <[email protected]> wrote:
>> Dear all,
>>
>> I have a county level panel data for two years: 2002 and 2008. I want
>> to create a binary variable "low" which categorizes counties by median
>> value of variable stroke in 2002. For example.
>>
>> County Year Avg stroke Low
>> A 2002 0.12 1
>> B 2002 0.17 1
>> C 2002 0.20 1
>> D 2002 0.24 0
>> E 2002 0.28 0
>> A 2008 0.10
>> B 2008 0.11
>> C 2008 0.34
>> D 2008 0.45
>> E 2008 0.23
>>
>> In year 2002, the median value of stroke is 0.20, and I have coded
>> counties with avg stroke <= median stroke as low. so, A, B, C are
>> low=1 and D.E are low=0.
>> Now I want to code A,B, C in 2008 as low=1 and D,E as low=0. I do not
>> want to consider abg stroke in these counties in 2008. Is there a
>> simple way to complete the column "low"?
>> Hope my query is clear.
>
> Not quite. Do you want to code A,B,C in 2008 as low=1 because their value
> was 1 in 2002? or because their 2008 value is below the 2002 median value?
> See which one fits from below. (Or provide more info).
>
> Best, Sergiy Radyakin
>
>
> clear
> input str1 County Year Avgstroke Low
> A 2002 0.12 1
> B 2002 0.17 1
> C 2002 0.20 1
> D 2002 0.24 0
> E 2002 0.28 0
> A 2008 0.10 .
> B 2008 0.11 .
> C 2008 0.34 .
> D 2008 0.45 .
> E 2008 0.23 .
> end
>
> bys County (Year): replace Low=Low[1] // 2002 must be smallest
> list, clean noobs
>
> clear
> input str1 County Year Avgstroke Low
> A 2002 0.12 1
> B 2002 0.17 1
> C 2002 0.20 1
> D 2002 0.24 0
> E 2002 0.28 0
> A 2008 0.10 .
> B 2008 0.11 .
> C 2008 0.34 .
> D 2008 0.45 .
> E 2008 0.23 .
> end
>
> //centile Avgstroke
> //local medianstroke=r(c_1)
>
> local medianstroke = 0.20
> replace Low = (Avgstroke<=`medianstroke')
> list, clean noobs
>
>
>
>>
>> Thanks.
>> Shikha
>> *
>> * 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/