Date: Tue, 20 Nov 2007 07:55:36 -0700
Reply-To: ViAnn Beadle <vab88011@gmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: ViAnn Beadle <vab88011@gmail.com>
Subject: Re: Question Regarding Importing Comma Delimited and Fixed Width
Text Files
In-Reply-To: <2BDDE596EB04B6459ADDF6592D8AE31051C54E@rowlandsrvr.RowlandReading.local>
Content-Type: text/plain; charset="us-ascii"
Read the text data as comma delimited (as you have already tried) but make
sure that the scorestring is read as alphanumeric. Then you can trundle
through the string, two characters at a time to pluck out your score
variables:
VECTOR score(15).
LOOP #i=1 to 30 by 2.
COMPUTE score(#i)=NUMBER(SUBSTRING(scorestring,#i,2),f2.0).
END LOOP.
Here's what's happening:
The VECTOR command creates 15 variables.
The LOOP sets an index value which is 1, 3, 5, ...
The COMPUTE command use the SUBSTRING function to pick up 2 characters from
the scorestring variable starting at the index value. It then applies the
NUMBER function to convert the string to a number.
-----Original Message-----
From: Justin Meyer [mailto:justin.meyer@rowlandreading.org]
Sent: Tuesday, November 20, 2007 7:29 AM
To: ViAnn Beadle; SPSSX-L@LISTSERV.UGA.EDU
Subject: RE: Question Regarding Importing Comma Delimited and Fixed Width
Text Files
ViAnn:
The characters always start in the same column within the string. They
are always numbers. Example: JohnDoe,123701110517,ImaginarySchool. In
this example, The student's name is John Doe, subtest score 1 is 12,
subtest score 2 is 37, subtest 3 score is 01, subtest 4 score is 11 and
subtest 5 score is 05, subtest 6 score is 17, and the student goes to
Imaginary School. The scores always take up the same number of
characters, i.e., score 1 is always the first and second characters
after the comma, score 2 is always the third and fourth characters after
the comma, but because the student name will be a different length each
time, the number of characters in from the very beginning will always be
different. Thanks for your help.
____________________________________
Justin Meyer
Rowland Reading Foundation
phone: 866-370-7323 fax: 608-204-3846
____________________________________
-----Original Message-----
From: ViAnn Beadle [mailto:vab88011@gmail.com]
Sent: Tuesday, November 20, 2007 7:57 AM
To: Justin Meyer; SPSSX-L@LISTSERV.UGA.EDU
Subject: RE: Question Regarding Importing Comma Delimited and Fixed
Width Text Files
Do the subtest scores always start in the same column? What do they look
like--are they numbers or something else?
It's fairly easy to split the 30 character string into separate
variables
via syntax--that should not be prone to errors. The solution depends
upon
more information from you.
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Justin Meyer
Sent: Monday, November 19, 2007 4:29 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Question Regarding Importing Comma Delimited and Fixed Width
Text
Files
I am a beginning SPSS user. I am trying to import a text file (.txt)
into SPSS 15.0. The text file is comma delimited except for the subtest
scores. There are 15 subtests in the data, each of which is represented
by a two character score. These two character scores are in a 30
character string, with no commas or anything else separating the scores.
When I attempt to import this data into SPSS as a comma delimited file,
I get one 30 character variable that includes the data from all 15
subtests rather than 15 two character variables. Can I fix this problem
when I import the data? I would prefer to avoid breaking the one
variable into other variables after it is imported as there are a large
number of these (not just one set of 15 subtests) and it would be prone
to error. It is likely that I can have the test data resent as
completely comma delimited or fixed width but there must be a way to
work with what I have. Why would this format be the default way to
receive the data? Wouldn't a file that was completely comma delimited or
fixed width make more sense? FYI- I have very little experience with
syntax but I am willing to work with it if that is the only way.
Thank you for any help you can provide.
____________________________________
Justin Meyer
Researcher
Rowland Reading Foundation
1 South Pinckney Street, Suite 324
Madison, WI 53703
phone: 866-370-7323 fax: 608-204-3846
www.rowlandreading.org <http://www.rowlandreading.org/>
____________________________________
=======
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD