Statalist


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

Re: st: "reshape" data


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: "reshape" data
Date   Thu, 29 May 2008 15:05:13 -0500

On May 29, 2008, at 1:33 PM, mac.stata wrote:
Does anyone of you know an easy and fast way to deal with the following data structure:

- I have a large survey data set containing data on individuals (unique records per individual over the complete data set)
- the survey is/was carried out each year
- within every year, there are variables like trust_1, trust_2, trust_3 trust_4, each for a specific issue addressed
- I would like to have a data set with the individual data (basic characteristics) plus one variable "trust"; e.g. if individual A has entries in trust_1, trust_2 and trust_3, I would like to have three entries for individual A containing the basic characteristics and each of the trust variables named as trust, so that in the end I could regress on trust!

How would I do that?

Your subject already has the answer: use -reshape-. Unfortunately, you indicate that each individual is measured over multiple years, but you don't say how year is represented in your current dataset. Setting that aside, then, if your individuals are indexed by a variable named "id", you'd do the following:

reshape long trust_, i(id) j(item)
ren trust_ trust

Incorporating year into this will depend on how your data are structured, but won't be difficult. I'd suggest looking at the examples in [D] -reshape-.


-- Phil

*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index