[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
David Kantor <kantor.d@att.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: -reshape long- |

Date |
Sun, 10 Aug 2008 14:09:03 -0400 |

At 01:20 AM 8/10/2008, Mandy Jia wrote:

Your command looks correct. The age filter is a separate matter (and I think you really meant -drop if age~=19 & age~=20).Hi all, I'm not familiar of the command -reshape-. So I was wondering if anyone could help me with an example of how to use -reshape- command. The data set I'm working on looks like this(w means wage) ------------------------------------------------------------------------ - id age80 age81 age82 age93 age84 w80 w81 w82 w83 w84 1 18 19 20 21 22 10 11 13 14 14.2 2 19 20 21 22 23 15 16 16 14 15 3 17 18 19 20 21 9 9 10 11 11.4 --------------------------------------------------------------------- When I reshape the data set, I want to limit the age to the range [19,20]. In order to use fixed effects and random effects models to analyze, I want to reshape the data into: --------------------------------------------------------------------- id age w year 1 19 11 81 1 20 13 82 2 19 15 80 2 20 16 81 3 19 10 82 3 20 11 83 --------------------------------------------------------------------- What I tried is as follows: .reshape long age w ,i(id) j(year) .drop if age~=19 | age~20 .sort id age My question is, is there any better way to do this? I'm not sure if what I did is OK, although I havn't found any weired thing in the result now.

You may want to inspect the data after the reshape -- before the age filter -- to convince yourself that it did what you wanted.

Also, I assume that in your data example you meant age83, rather than age93.

I can't comment on how this fits in fixed effects and random effects models. But in any case, it is good to be acquainted with -reshape-, and in most cases, a long shape is the most useful.

HTH.

--David

*

* 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/

**References**:**st: -reshape long-***From:*Man Jia <jia.m@neu.edu>

- Prev by Date:
**st: Linear regression; where is the correlation coefficient** - Next by Date:
**Re: st: -reshape long-** - Previous by thread:
**st: -reshape long-** - Next by thread:
**Re: st: -reshape long-** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |