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 (April 1998)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 1 Apr 1998 18:09:36 -0600
Reply-To:     "Tverdek, Edward" <etverdek@SPSS.COM>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From:         "Tverdek, Edward" <etverdek@SPSS.COM>
Subject:      Re: Variable separation
Comments: To: "M. MILLS" <m.mills@FRW.RUG.NL>

Melinda,

SPSS's own invaluable David Matheson is the first to come up with one of the "easier ways" I mentioned. Since the values you have are already 0s and 1s, you can extract the actual digits rather than, as I suggested, computing a logical variable based on the value of the division remainder (MODulo). In addition, 7-#i is, of course, equivalent to the absolute value of #i-7. The following simplification from David will get you the same results with less room for headaches.

VECTOR x(7). LOOP #i=1 TO 7. COMPUTE x(#i)= MOD(TRUNC(v1/10**(7-#i)),10). END LOOP. formats x1 to x7 (f3). LIST.

Again, I hope this helps.

Ed Tverdek SPSS Technical Support

>---------- >From: Tverdek, Edward >Sent: Wednesday, April 01, 1998 1:42 PM >To: SPSSX-L@UGA.CC.UGA.EDU; 'M. MILLS' >Subject: RE: Variable separation > >Melinda, > >How you might extract these values into an array of >dichotomous variables will depend on how you've read >the "v1" variable from the .dbf file. If you have >read it as a string, you can extract the individual >variables with a series COMPUTE statements involving >the SUBSTR (substring) command. If you were hoping to >treat the resulting dichotomies as numeric, it would be >necessary to convert them to this format, either on the >fly with the NUMBER function or with a RECODE...(CONVERT) >...INTO once each new dichotomy has been extracted. > >This being said, you might have an easier time of it if you >can read the "v1" variable as numeric and extract your >individual dichotomous variables conditionally. Here's a >small sample job which seems to work for the cases you provide, >and which I think might be useable in general (you would need >to adjust some arguments in obvious places depending on how >long the string of digits is and how many variables you wanted >to pull out of it). There may be an easier way to do this, >but this example ought to get you started. > >I hope this helps, > >Ed Tverdek >SPSS Technical Support > >************************************************ > >*This just reads a few cases along the lines you describe. > >new file. >data list /v1 1-7. >begin data >0011001 >1001000 >0110010 >0000000 >1111111 >1010101 >0101010 >1111000 >0000111 >end data. > > >*Here's the relevant part. > >COMPUTE newv1=v1+10000000. >VECTOR x(7). >LOOP #i=1 TO 7. >COMPUTE x(#i)=(MOD(TRUNC(newv1/10**(ABS(#i-7))),10) NE 0). >END LOOP. >LIST. > > > > > >---------- >From: M. MILLS[SMTP:m.mills@FRW.RUG.NL] >Sent: Wednesday, April 01, 1998 4:02 AM >To: SPSSX-L@UGA.CC.UGA.EDU >Subject: Variable separation > >Hello everyone, >I would like some advice regarding the 'splitting' or 'separating' of >one variable into several parts. I received a series of '*.dbf' files, >which I transferred to SPSS. However, I found that >certain series of questions were collapsed into one variable. For >example, the 'type of education' variable, is currently: > v1 >0011001 >1001000 >0110010 >etc_ >Whereas, I need it arranged into seven separate dichotomous variables >with values of 0 & 1. > >v1 v2 v3 v4 v5 v6 v7 >0 0 1 1 0 0 1 > >Does anyone have any suggestions about how to separate these >variables? Thank you very much for taking the time to help. >Melinda > >Melinda Mills >Population Research Centre, Faculty of Spatial Sciences >P.O. Box 800 >9700 AV Groningen >The Netherlands >Tel: +31 50 363 3898 Fax: +31 50 363 3901 >e-mail: M.Mills@frw.rug.nl > >


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