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 (February 2002)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 22 Feb 2002 08:12:05 -0800
Reply-To:     Judy Butler <jabutler66@yahoo.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Judy Butler <jabutler66@yahoo.com>
Subject:      Re: Trying to make move data from multiple cases into a single
              case
Comments: To: jk <jklein@IGC.ORG>
In-Reply-To:  <003501c1bba5$5003aa60$c818f7a5@jkleinigc.org>
Content-Type: text/plain; charset=us-ascii

I think you want to use the aggregate command. First use the lag function to assign a number to each row of each case. For example,

if (ED ne lag(ED, 1)) rownum = 1. if (ED = lag(ED, 1)) rownum = lag(rownum, 1) + 1.

This will assign 1 to the first row and increase it for each subsequent row associated with each ED. Double check the lag function to make sure that it works the way I'm saying it will.

Then, add in some commands like (and you may be able to use something else to do this)...

do if (rownum = 2). compute var1_2 = var1. compute var2_2 = var2. else if (rownum = 3). compute var1_3 = var1. compute var2_3 = var2. (I think you get the idea) end if.

Then aggregate aggregate outfile = * /break = ED /var1 var2 = first(var1 var2) /var1_2 var2_2 = max(var1_2 var2_2) /var1_3 var2_3 = max(var1_3 var2_3).

More advanced programmers may have a better solution, but this will work.

--- jk <jklein@IGC.ORG> wrote: > Hello, I am using 2 data sets; one which contains > voting data and another > which contains election monitoring data. I need to > combine the two data > sets. The voting data contains one row > (observation) for each election > district (ED). The monitoring data, on the other > hand, contains multiple > observations for some EDs. Some EDs are represented > by one row, and others > are represented by up to 12 rows. > > I want to combine the voting and monitoring data > sets using ED as the key > variable. In order to do this, I want to move the > 2nd through Nth row for > each unique ED into the first row for that ED. I > would like to write a > program that will move the second observation and > append it to the end of > the first row of data, using similar variable names > with an incrementing > character at the end of each name to identify which > row it came from. this > way, I'll still have all the monitoring information > in the monitoring file, > but there will be only one row per ED. Then I can > combine the voting and > monitoring data sets and have only one row per ED. > Below is a hypothetical > sample portion to show you what I'm taking about. I > suspect I should create > a DO IF statement, using Create or Compute to move > data, then delete the > row. > > Thus this... > > ED var1 var2 var3 > var4 > 62079 3 3 > 84728 56 > 62085 2 3 > 62087 2 3 > 63004 2 1 > 63004 3 8 O118 > 45 > 63006 2 1 > 63006 2 1 > 63006 2 3 > > ...would become this: > > ED var1 var2 var3 > var4 EDa var1a var2a > var3a var4a EDb var1b > var2b > 62079 3 3 > 84728 56 > 62085 2 3 > 62087 2 3 > 63004 2 1 > 63004 3 8 > O118 45 > 63006 2 1 > 63006 2 1 > 63006 2 > 3 > > If you can offer any assistance, I'd be grateful. > > Dr. Josh Klein > 82 Hamilton Ave. New Rochelle, NY 10801 > H 914 576 5285 W 212 817 1948 > jklein@igc.org

===== ****************************************** Check out the latest pictures of Emily at http://www.users.qwest.net/~bcj5 ******************************************

__________________________________________________ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com


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