LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 1998)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 28 Oct 1998 07:40:47 GMT
Reply-To:     Ronald Dekker <R*Dekker@KUB.NL>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From:         Ronald Dekker <R*Dekker@KUB.NL>
Organization: Tilburg University
Subject:      Re: Help with data
Comments: To: SAS-L@VTVM1.CC.VT.EDU, STAT-L@VM1.MCGILL.CA

In article <3636acf5.14024365@news.ucla.edu> >I need help getting some data into Stat software for analysis. I can use SAS, >SPSS, or Stata. Here's the question: > >My data is currently in the following format in Excel, with one Person on each >line for each year: > >Name Year var1 var2..... var10 >Person1 >Person1 >Person1 >Person2 >Person2 >Person3 >Person3 >Person3 > > Persons may have data for different numbers of years. Each person has > a >unique name. I need to get this data into a format where I can correlate >year-to-year changes in the observed variables for each person, as well as >regress YearX on previous years. Basically, I think I need to get each > person's >data on one row, like the following: > >Person 1 var1Year1 var2year1... var1year2 var2year2.... >Person 2 var1Year1 var2year1... var1year2 var2year2.... > > And so on. > >Anyone have any ideas? > >Please CC via e-mail if possible. > >Thanks, > > > >Joseph Sherman >UCLA Dept of Sociology >jsherman@ucla.edu

This is the way this is done in STATA: (STATA command between ^ ^)

Description -----------

^reshape^ converts data from wide to long and vice versa.

^reshape groups^ names a single variable that will record the grouping variable along with the values it will assume. The grouping variable is the variable that will be created when converting from wide to long and the values are the values it will assume. The values are also the suffixes applied to the var- iable names when converting to wide.

^reshape variables^ identifies the variable(s) for which there are related observations. ^reshape cons^ identifies the variable(s) that are "relatively" constant; that is, that do not change across related observations. ^reshape query^ shows the current definitions.

^reshape long^ converts data to long format. ^reshape wide^ converts to wide.

Example -------

id sex inc80 inc81 inc82 id year sex inc ------------------------------- ---------------------- 1 0 5000 5500 6000 1 80 0 5000 2 1 2000 2200 3300 1 81 0 5500 3 0 3000 2000 1000 1 82 0 6000 2 80 1 2000 2 81 1 2200 2 82 1 3300 3 80 0 3000 3 81 0 3300 3 82 0 1000

. ^reshape groups year 80-82^ . ^reshape vars inc^ . ^reshape cons id sex^

. ^reshape long^ (goes from left-form to right) . ^reshape wide^ (goes from right-form to left)

Greetings

Ronald Dekker (note: Change * to . when replying by E-mail) Tilburg Institute for Social Security Research Tilburg University The Netherlands


Back to: Top of message | Previous page | Main SPSSX-L page