expand 2
bysort var : replace var = . if _n == 2
or
expand 2
sort var
replace var = . if mod(_n,2)
Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of
> Daniel Mueller
> Sent: 10 February 2004 16:17
> To: Statalist
> Subject: st: rearranging observations within a variable
>
>
> Hi.
>
> There's probably a neat trick to that, but can't find it...
>
> I have one variable:
> +-----+
> | var |
> |-----|
> 1. | 1 |
> 2. | 3 |
> 3. | 5 |
> 4. | 7 |
> 5. | 9 |
> |-----|
> 6. | 11 |
> 7. | 13 |
> 8. | 15 |
> 9. | 17 |
> 10. | 19 |
> +-----+
>
> The observations of this variable I want to rearrange to
> arrive at the following:
> +-----+
> | var |
> |-----|
> 1. | 1 |
> 2. | . |
> 3. | 3 |
> 4. | . |
> 5. | 5 |
> |-----|
> 6. | . |
> 7. | 7 |
> 8. | . |
> 9. | 9 |
> 10. | . |
> +-----+
> i.e. I have to -expand- the data set to get running
> observation numbers with missing values for observations, which were
> previouly missing.
>
> How can I do that??
>
> Thanks a bunch in advance,
> greetings,
> Daniel
>
>
>
> *
> * 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/
*
* 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/