More observations than individuals - convert rows to variables - reshape????
I have a HH dataset consiting of about 50 or so subsets which I am trying to merge together. The following problem occures. In some of these datasets there are more observations then individuals in the survey because data on jobs has been coded as job1, job2, job3 etc... each taking a seperate row.
So in my dataset there are three ID variables and the job variable and together they form a unique ID.
Now what I need is to have the additional (job) rows transformed to variables so that I end up with exactly the number of individuals as in the other data sets. Meaning all information that is now contained in a single job row (lets say for job3) such as days worked in this job per month or hours worked in this job per day should become variables (columns).
I've drawn a rudementary graph below. Hope it will help...
Just to clarify again. The table shows how rows 3,7,8 become variables in the second table (JOB3 missing because of space). Those rows that had second or third job become variables and in those the individuals who have one job only are missing. Can't be that difficult. Thanks again everyone for helping...
Re: More observations than individuals - convert rows to variables - reshape????
You're right that -reshape- is the tool for this. However, for most purposes data in a "long format" (each job on a separate line) is easier to analyse in Stata - if I were you I would use -reshape long- to make all the datasets like your first example and then -append- them together. You can always -reshape wide- again later if needed.
If you are still keen to use a wide format your -reshape- command probably needs to be something along the lines of:
reshape wide days hours, i(id1 id2 id3) j(job)
(note that you can reshape multiple variables simultaneously - days and hours in the example above)
For more specific advice you would need to show us the exact command that you used, and its exact output, and preferably a real example of your data. It's usually easiest to copy and paste from the Stata results window, and to paste the results inside CODE tags so that they appear correctly in the web browser.