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 (November 2003)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 19 Nov 2003 09:36:02 +1100
Reply-To:     Simon Freidin <s.freidin@iaesr.unimelb.edu.au>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Simon Freidin <s.freidin@iaesr.unimelb.edu.au>
Subject:      Re: Write variable name into new variable
Comments: To: "Steiner, Markus" <markus.steiner@uba.de>
In-Reply-To:  <7677B11D9B2F8E429EE90D36C2228F0602985E8A@hermes-rz8.uba.de >
Content-Type: text/plain; charset="us-ascii"; format=flowed

data list list/ID (f1) loc (a1) date (a6) x y z (3f3). begin data. 1 N 12.11. 12 22 53 2 W 23.10. 34 11 34 3 N 24.08. 14 31 76 end data.

varstocases /make value from x y z/index=name(value). list.

Output: ID LOC DATE NAME VALUE

1 N 12.11. X 12 1 N 12.11. Y 22 1 N 12.11. Z 53 2 W 23.10. X 34 2 W 23.10. Y 11 2 W 23.10. Z 34 3 N 24.08. X 14 3 N 24.08. Y 31 3 N 24.08. Z 76

Unfortunately you have to choose between getting COL or NAME created by the index subcommand, it won't do both simultaneously. Anyone have a workaround?

To create COL: varstocases /make value from x y z/index=col.

cheers Simon

At 04:17 PM 11/18/2003 +0100, Steiner, Markus wrote: >Hello, > >while partly transposing a data set I would need to write the variable >name of some variables into a new variable, so that the information, from >which variable are the values after transposition are still available. > >Here an example: > >Original data > >ID loc date x y z >1 N 12.11. 12 22 53 >2 W 23.10. 34 11 34 >3 N 24.08. 14 31 76 > >with the folowing code: > > >DATA LIST FREE / id (N) loc (A) date (EDATE) var1 (N) var2 (N) var3 (N). >BEGIN DATA >1 N 12.11.03 12 22 53 >2 W 23.10.03 34 11 34 >3 N 24.08.03 14 31 76 >END DATA. > >IF ( MISSING(LAG($CASENUM)) OR id <> LAG(id) ) ROW=1. >IF(MISSING(ROW)) ROW=LAG(ROW)+1 . >VECTOR VAR=var1 TO var3 . >LOOP COL=1 TO 3 . >COMPUTE value=VAR(COL). >XSAVE OUTFILE 'tmp_flip.sav' / KEEP id loc date row col value . >END LOOP. >EXECUTE. >GET FILE 'tmp_flip.sav'. > >it looks like: > >ID loc date row col value >1 N 12.11. 1 1 12 >1 N 12.11. 1 2 22 >1 N 12.11. 1 3 53 >2 W 23.10. 1 1 34 >2 W 23.10. 1 2 11 >2 W 23.10. 1 3 34 >3 N 24.08. 1 1 14 >3 N 24.08. 1 2 31 >3 N 24.08. 1 3 76 > > >and that's what I want: > >ID loc date name col value >1 N 12.11. X 1 12 >1 N 12.11. Y 2 22 >1 N 12.11. Z 3 53 >2 W 23.10. X 1 34 >2 W 23.10. Y 2 11 >2 W 23.10. Z 3 34 >3 N 24.08. X 1 14 >3 N 24.08. Y 2 31 >3 N 24.08. Z 3 76 > >Any help would be very helpful. > >Regards. > >Markus

Research Database Manager and Analyst Melbourne Institute of Applied Economic and Social Research The University of Melbourne Melbourne VIC 3010 Australia Tel: (03) 8344 3601 Fax: (03) 8344 5630 http://www.melbourneinstitute.com/hilda/


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