Date: Mon, 12 Jul 2010 01:12:36 -0400
Reply-To: Richard Ristow <wrristow@mindspring.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <wrristow@mindspring.com>
Subject: Re: how to restructure data file
In-Reply-To: <29100003.post@talk.nabble.com>
Content-Type: text/html; charset="us-ascii"
<html>
<body>
At 07:14 PM 7/7/2010, Bruce Weaver wrote:<br><br>
<blockquote type=cite class=cite cite="">Gene & Albert-Jan, I don't
think your solutions are creating all of the variables that Martin
wants. I think you need to do something like the
following--although there are no doubt more elegant ways to do
it!</blockquote><br>
Bruce notes that the problem is to create variables for sessions that are
provided for in the study, but for which no subject in the file has any
data. CASESTOVARS can roll up the file and create variables for all
sessions that <i>are</i> there, but not for all that <i>could be</i>
there.<br><br>
Bruce's solution is, using a macro, to create a dummy record (for
'subject' 00) containing all the desired variables, and catenate this
ahead of the file actually created.<br><br>
An alternative (not tested) is to create and catenate the dummy subject
<i>before</i> the <tt><font size=2>CASESTOVARS</font></tt>, using
<tt><font size=2>LOOP</font></tt> and <tt><font size=2>XSAVE</font></tt>.
It's similar logic, but it takes less code. <b>NOT TESTED:<br><br>
</b><tt><font size=2>* This requires that the original data be in
dataset DATA, .<br>
* and a scratch file (not dataset) named DUMMY be
available.<br><br>
<br>
* Initial dummy record, as Bruce had it.<br>
data list list / ID(a2).<br>
begin data<br>
00<br>
end data.<br><br>
* XSAVE loop to create 'records' for sessions 1 to 25 .<br>
* (These records don't need variables a1 to c6; those .<br>
* will be added when the files are
catenated.) .<br><br>
LOOP Session = 1 TO 25.<br>
. XSAVE OUTFILE=Dummy.<br>
END LOOP.<br>
EXECUTE /* This one is needed */.<br><br>
* Catenate dummy and real
data:
.<br>
ADD FILES<br>
/FILE=Dummy<br>
/FILE=DATA.<br><br>
* Now CASESTOVARS should give what is
wanted: .<br>
* (I've copied Gene's CASESTOVARS and Bruce's SELECT IF).<br><br>
casestovars id=id/index=session.<br>
select if (ID NE "00").</font> </body>
<br>
</html>
=====================
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
|