Specifically, each subject's data has 25 lines, each containing 5 variables.
The first variable in each line names the condition (stimulus) used to generate
the rest of the data on that line. If this data file was a TEXT file, I would
write data list syntax, including the specifier "RECORDS = 25", and define each
variable by line "/1.../2.../3.../25" and column position (using fixed format),
or by serial position (using free field format). However, I can find no way to
do this with a spreadsheet data file. When it comes to spreadsheets, the only
format I have ever used lists all data on a single line per subject. Is there
some command one uses to tell SPSS how many lines per subject there are in a
spreadsheet?
In case it makes a difference to your answer, the type of analyses I want to
involve scale development -- factor analysis, internal consistency reliability,
factor analysis, creation of composite variables (summing items on different
lines), etc.
If there is no simple solution to this question, what is the easiest way to
collapse the 25 lines per subject into one line per subject (with all 125
variables on that single line)?
Thanks for any help with this.
John Poole
--
***************************************
John H. Poole, Ph.D.
Department of Psychiatry
University of California Medical Center
4150 Clement Street (116C)
San Francisco, CA 94061, USA
Phone: 650-281-8851 Fax: 415-750-6996
Email: po...@itsa.ucsf.edu
***************************************
> Specifically, each subject's data has 25 lines, each containing 5 variables.
> The first variable in each line names the condition (stimulus) used to generate
> the rest of the data on that line. If this data file was a TEXT file, I would
> write data list syntax, including the specifier "RECORDS = 25", and define each
> variable by line "/1.../2.../3.../25" and column position (using fixed format),
> If there is no simple solution to this question, what is the easiest way to
> collapse the 25 lines per subject into one line per subject (with all 125
> variables on that single line)?
Yes, I would recommend collapsing the 25 lines per subject into one
long line per subject. It's a bit unclear to me whether the file
you're referring to is an SPSS "spreadsheet" or something else, e.g.,
Excel, Quattro.
1) If the data are in a non-SPSS spreadsheet file:
Import into SPSS in the "regular way."
Then, do the following, which is what you would do if the
data already are in an SPSS data file:
2) Assuming you have an ID number for each subject, and relying
on your stimulus variable ('STIMNUM'):
* Separate the lines into different files .
* The x1 to xN list refers to the variables that
* are identical on each line .
do if (STIMNUM =1) .
xsave file = 'rec1.sav'/ rename = (x1 to x5= x11 to x51) .
else if (STIMNUM = 2) .
xsave file = 'rec2.sav'/ rename = (x1 to x5 = x12 to x52) .
.....
else if (STIMNUM = 25) .
xsave file 'rec25.sav' rename = (x1 to x5 = x125 to x525) .
end if .
* Put the file back together .
match files file = 'rec1.sav/file = 'rec2.sav' etc... /by = ID .
There is one catch to the preceding: Only 20 XSAVE commands are allowed
in a single run of syntax. Presumably, there is some similar limit
on MATCH FILES. So, you will have to do this in two chunks, i.e.,
split out the first say 12 records, combine them, split out the
next 13 records, combine them, then combine the two chunks.
There is probably a more elegant way to do this, but this
is the most intuitively obvious way I can think of .
3) The klutzy but perhaps easiest way:
Write out the original file as a text file (Save As text should
do it), then read in the data with data list as a multiple
record per subject data file, per your comments.
Regards,
--
=-=-=-=-=-=-=-=-=-==-=-=-=
Mike Lacy, Ft Collins CO 80523
voice (970) 491-6721 fax (970) 491-2191
There is another way: use the AGGREGATE command.
Something like this:
sort cases by subject.
numeric X101 to x225.
vector x = x101 to x225.
if range(stimnum,1,25) do.
+ compute x(100+5*stimnum+1) = x1.
+ compute x(100+5*stimnum+2) = x2.
+ compute x(100+5*stimnum+3) = x3.
+ compute x(100+5*stimnum+4) = x4.
+ compute x(100+5*stimnum+5) = x5.
end if.
agg outfile=* /presorted /break=subject
/x1 to x125 = first(x101 to x225).
- Moshe