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: Generating a row of dummies per ID based on multiple lines of panel data


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Generating a row of dummies per ID based on multiple lines of panel data
Date   Mon, 10 Mar 2014 09:31:00 +0000

I think this is the wrong way round. You think you need dummies as a
means to an end, restructuring your data to monthly observations, but
I can't see that.

You need to work with monthly dates (combine year and month dates
using the -ym()- function), to -expand- using your duration variable
and then replace dates in sequence.

Incidentally, while showing .png makes your set-up very clear, it
makes it difficult to copy and paste (I could be missing a trick) and
thus to play with your sample data
and thus to suggest code.


Nick
[email protected]


On 10 March 2014 08:55, Mark Egan <[email protected]> wrote:
> Hello,
>
> I simplified this problem to explain it easier: there are multiple observations of the same individual over a maximum of 35 months; from January 1990 to December 1992. Some people are present for the whole period, others drop in and out of the sample over time. Each observation per person corresponds to a different spell of employment or unemployment for that person. One spell could be a month or several years, as long as it is continuous.
>
> I want to create a row of 35 dummies for each person, indicating whether they were employed (using a value of 0), unemployed (using a value of 1) or missing data (using a value of .) for that month. The idea is I would then reshape the data so that it was in a long format with (up to) 35 observations per person, rather than the grouping system used now.
>
> Problem - The data now look like this:
> https://www.dropbox.com/s/7o2ita0vxoxwur2/problem.png
>
> End goal - I want them to look like this:
> https://www.dropbox.com/s/on2z48qdrcrrrto/end%20goal.png
>
> For the monthly dummies (m1, m2 ...), the desired coding is 0= employed, 1= unemployed, . = missing data for that month. The ultimate end goal I think I can reshape myself, but I don't know how to get to the state with monthly dummies.
>
> Hope I've explained that well enough and thanks a lot for reading.
>
> Regards,
> Mark
> --
> The University of Stirling has been ranked in the top 12 of UK universities for graduate employment*.
> 94% of our 2012 graduates were in work and/or further study within six months of graduation.
> *The Telegraph
> The University of Stirling is a charity registered in Scotland, number SC 011159.
>
>
> *
> *   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/


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