Hello, I’m working on a submission to the NIH NDA Data archive, for which I need to convert my SPSS file to CSV, and then make a modification to the CSV file. It requires inserting a row above the variable names, which is used to identify what
sort of data is being reported. The file currently looks like this:
The file needs to look like this:
So my question is: is there a way to use SPSS syntax to add that row with two cells of text above the variable names before/while converting to CSV? I will be doing this for many different datasets so it would be ideal to have it built
into my syntax. Thanks in advance for your help! Jed Jacobson Research Coordinator University of Washington ALACRITY Center |
You could try the WRITE command with a DO IF to write that extra line on the first case ($CASENUM eq 1). Where does that extra text come from? If that doesn't work out, a little Python code to write csv files could do the job. I can help with that if you need to go that way. On Mon, Apr 6, 2020 at 5:38 PM Jed H Jacobson <[hidden email]> wrote:
|
Jon, When I first saw the email I thought that something like the following would work but then I realized that I didn't know if a line of data was a case or a repeated measure on a case which raises the question of how many records there should be. Do if (ndar_subject = 1). WRITE OUTFILE=’/NIH_NDA_data/NDAR_Subj001.txt’ RECORDS=3 /1 "ndar_subject" ndar_subject /2 "Var1" "Var2" "Var3" "Var4" /3 Var1 "," Var2 "," Var3 "," Var4. EXECUTE. End if. I was left thinking that this might be done more easily in Python. -Mike Palij On Mon, Apr 6, 2020 at 10:40 PM Jon Peck <[hidden email]> wrote:
|
Hi, Mike, I'm aware of those files with meta information above. How about this? DO IF $casenum = 1. PRINT OUTFILE = "data.csv" / "ndar_subject;1". PRINT OUTFILE = "data.csv" / "var1;var2;var3;var4". END IF. PRINT OUTFILE = "data.csv" /var1,";", var2,";", var3,";",var4. EXECUTE. Mario Giesel Munich, Germany ---
Am Dienstag, 7. April 2020, 05:01:09 MESZ hat Michael Palij <[hidden email]> Folgendes geschrieben:
Jon, When I first saw the email I thought that something like the following would work but then I realized that I didn't know if a line of data was a case or a repeated measure on a case which raises the question of how many records there should be. Do if (ndar_subject = 1). WRITE OUTFILE=’/NIH_NDA_data/NDAR_Subj001.txt’ RECORDS=3 /1 "ndar_subject" ndar_subject /2 "Var1" "Var2" "Var3" "Var4" /3 Var1 "," Var2 "," Var3 "," Var4. EXECUTE. End if. I was left thinking that this might be done more easily in Python. -Mike Palij On Mon, Apr 6, 2020 at 10:40 PM Jon Peck <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |