NDA Submission SPSS Syntax Question

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

NDA Submission SPSS Syntax Question

Jed H Jacobson

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:

 

Var1

Var2

Var3

Var4

Data

Data

Data

Data

Data

Data

Data

Data

 

The file needs to look like this:

 

ndar_subject

1

Var1

Var2

Var3

Var4

Data

Data

Data

Data

Data

Data

Data

Data

 

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

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: NDA Submission SPSS Syntax Question

Jon Peck
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:

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:

 

Var1

Var2

Var3

Var4

Data

Data

Data

Data

Data

Data

Data

Data

 

The file needs to look like this:

 

ndar_subject

1

Var1

Var2

Var3

Var4

Data

Data

Data

Data

Data

Data

Data

Data

 

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

===================== 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


--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: NDA Submission SPSS Syntax Question

Mike
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:
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:

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:

 

Var1

Var2

Var3

Var4

Data

Data

Data

Data

Data

Data

Data

Data

 

The file needs to look like this:

 

ndar_subject

1

Var1

Var2

Var3

Var4

Data

Data

Data

Data

Data

Data

Data

Data

 

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

===================== 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


--
Jon K Peck
[hidden email]

===================== 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
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: NDA Submission SPSS Syntax Question

spss.giesel@yahoo.de
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:
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:

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:

 

Var1

Var2

Var3

Var4

Data

Data

Data

Data

Data

Data

Data

Data

 

The file needs to look like this:

 

ndar_subject

1

Var1

Var2

Var3

Var4

Data

Data

Data

Data

Data

Data

Data

Data

 

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

===================== 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


--
Jon K Peck
[hidden email]

===================== 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
===================== 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
===================== 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