File restructure question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

File restructure question

Beckstead, Jason
 
I have a file restructuring problem. Each case has 3 rows of data of the variable Y (see below). I want to get a new file structure in which each case has one row and 3 variables (e.g., Y1, Y2, & Y3). Normally I would just use the SPLIT FILE & CASESTOVARS commands to accomplish this. But here is the problem; I do not have the ID variable and the data are in an .SAV file. I know that I could go the long way and write out the data into ASCII as is and then use DATA LIST RECORDS=3 to read it back in to do this.  Can anyone suggest a bit of code to restructure the file without having to go the extra step?
 
data are in the following file structure
ID      Y
1       2.3
1       3.3
1       1.3
2       4.2
2       4.7
2       3.9
.      
.      
.      
N       1.9
N       2.1
N       3.3
 
 
Regards,
Jason
 
_____________________________________________________________
Jason W. Beckstead, Ph.D.       
  Associate Professor/Quantitative Methodologist
  University of South Florida College of Nursing
  12901 Bruce B. Downs Blvd., MDC22, Tampa, FL 33612, USA
  phone: +1.813.974.7667  fax: +1.813.974.5418          
 
 
Reply | Threaded
Open this post in threaded view
|

Re: File restructure question

Maguin, Eugene
Jason,

I think you are telling us that your data really doesn't have an id column
even though your example shows one.

Assuming this is true, the thing to do is to create an id column and then do
casestovars. Like this.

Compute id=1+trunc(($casenum-1)/3).

Gene Maguin




 >> I have a file restructuring problem. Each case has 3 rows of data of the
variable Y (see below). I want to get a new file structure in which each
case has one row and 3 variables (e.g., Y1, Y2, & Y3). Normally I would just
use the SPLIT FILE & CASESTOVARS commands to accomplish this. But here is
the problem; I do not have the ID variable and the data are in an .SAV file.
I know that I could go the long way and write out the data into ASCII as is
and then use DATA LIST RECORDS=3 to read it back in to do this.  Can anyone
suggest a bit of code to restructure the file without having to go the extra
step?

data are in the following file structure
ID      Y
1       2.3
1       3.3
1       1.3
2       4.2
2       4.7
2       3.9
.
.
.
N       1.9
N       2.1
N       3.3


Regards,
Jason

_____________________________________________________________
Jason W. Beckstead, Ph.D.
  Associate Professor/Quantitative Methodologist
  University of South Florida College of Nursing
  12901 Bruce B. Downs Blvd., MDC22, Tampa, FL 33612, USA
  phone: +1.813.974.7667  fax: +1.813.974.5418
  website:  http://personal.health.usf.edu/jbeckste/
<http://personal.health.usf.edu/jbeckste/>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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