| 
 |  | ||||
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: How Can I Create the Variable x?
From 
 
"Michael Blasnik" <[email protected]> 
To 
 
<[email protected]> 
Subject 
 
st: Re: How Can I Create the Variable x? 
Date 
 
Sun, 28 Jan 2007 23:18:31 -0500 
I think this does what you want:
bysort id (bsid): gen x=sum(bsid!=bsid[_n-1])
Michael Blasnik
----- Original Message ----- 
From: "Raphael Fraser" <[email protected]>
To: <[email protected]>
Sent: Sunday, January 28, 2007 9:12 PM
Subject: st: How Can I Create the Variable x?
I need help in creating the var x.
id bsid  x
1  22    1
1  22    1
1  52    2
1  87    3
2  43    1
2  43    1
2  11    2
3  28    1
4  33    1
I have tried,
bysort id bsid: gen x = _n
bysort id (bsid): gen x = _n
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
| © Copyright 1996–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |