SPSS Load Documents for ASC files

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

CharTam
Posts: 4
Joined: Tue Sep 29, 2015 2:43 pm

SPSS Load Documents for ASC files

Postby CharTam » Tue Sep 29, 2015 2:46 pm

Hi,
I am attempting to load an SPSS syntax file for a national database file in ASC format.

I am getting two error messages "this command is not permitted before the beginning of file definition commands" & "this command is not valid before a working file has been defined"

Here is an abridged sample of the syntax:

FILE HANDLE DATA / NAME="C:\Users\topila\documents\NIS_2011_Core.ASC"
*** Read data elements from the ASCII file ***.
DATA LIST FILE = 'NIS_2011_Core.ASC' FIXED /
AGE 1- 3

*** Specify write formats ***.
FORMATS
AGE (F3.0) /

*** Assign labels to the data elements ***.
VARIABLE LABELS
AGE "Age in years at admission"

*** Convert special values to system missing values ***.
RECODE AGE (-99 -88 -66=SYSMIS).

SAVE OUTFILE = 'NIS_2011_Core.SAV' / COMPRESSED.


**any suggestions are greatly appreciated!!**
JonPedersen
Posts: 119
Joined: Wed May 25, 2011 7:07 am
Contact:

Re: SPSS Load Documents for ASC files

Postby JonPedersen » Wed Sep 30, 2015 12:54 pm

Hi,
You have several errors.
The first is the relation between your file handle and data list statements. The file hanlde defines a full or partial parth that is used in stead of the whole or partial file path in another file related command. In your case the DATA LIST. SO most likely your data list will not find the right file. Also, you are missing ending dots all over the place. I would probably have used user missing in stead of system missing, but that is more of a preference.
Best
Jon
CharTam
Posts: 4
Joined: Tue Sep 29, 2015 2:43 pm

Re: SPSS Load Documents for ASC files

Postby CharTam » Thu Oct 01, 2015 3:04 pm

Jon- by stating that the Data List File will not find the right file because I'm including a partial path, does that mean the syntax should instead read: DATA LIST FILE ="C:\Users\topila\documents\NIS_2011_Core.ASC" ??
I am not an experienced programmer, but I was provided a load file for a federal database in order to convert an ASC file to SPSS. When I load the syntax as-is, the output is riddled with error messages: https://www.hcup-us.ahrq.gov/db/nation/ ... 1_Core.SPS

Any help you can give is greatly appreciated, I'm much more comfortable with SAS syntax but I have to use SPSS for this particular project!!
JonPedersen
Posts: 119
Joined: Wed May 25, 2011 7:07 am
Contact:

Re: SPSS Load Documents for ASC files

Postby JonPedersen » Fri Oct 02, 2015 8:25 am

Hi,
yes and no.
You may do one of two things:
First, with file handle

Code: Select all

FILE HANDLE MYDATAPATH /NAME="C:\Users\topila\documents". 
*** Read data elements from the ASCII file ***.
DATA LIST FILE = 'MYDATAPATH\NIS_2011_Core.ASC' FIXED / 
AGE 1- 3.

*** Specify write formats ***.
FORMATS AGE (F3.0).

*** Assign labels to the data elements ***.
VARIABLE LABELS 
AGE "Age in years at admission".

*** Convert special values to system missing values ***.
RECODE AGE (-99 -88 -66=SYSMIS).
* Rather than the recode, I would probably have used:.
MISSING VALUES AGE(-99,-88,-66).
SAVE OUTFILE = 'MYDATAPATH\NIS_2011_Core.SAV' .
Then without file handle:

Code: Select all

*** Read data elements from the ASCII file ***.
DATA LIST FILE = 'C:\Users\topila\documents\NIS_2011_Core.ASC' FIXED / 
AGE 1- 3.
* Rest of the stuff unchanged.
*** Specify write formats ***.
FORMATS AGE (F3.0).

*** Assign labels to the data elements ***.
VARIABLE LABELS 
AGE "Age in years at admission".

*** Convert special values to system missing values ***.
RECODE AGE (-99 -88 -66=SYSMIS).
* Rather than the recode, I would probably have used:.
MISSING VALUES AGE(-99,-88,-66).
SAVE OUTFILE = 'C:\Users\topila\documents\NIS_2011_Core.SAV' .
The file handle command is helpful when you write syntax files that you may move between computers, because you can define locations at the top of the file and then forget about them.
I have not tested, so I may have missed a dot or something somewhere. The program on the website is fine, your problem is probably the file reference. SPSS swamps you with error messsages if the file definition goes wrong.
Best
Jon
CharTam
Posts: 4
Joined: Tue Sep 29, 2015 2:43 pm

Re: SPSS Load Documents for ASC files

Postby CharTam » Mon Oct 05, 2015 5:26 pm

Thank you Jon- the syntax worked perfectly and I am so appreciative for the help!

Who is online

Users browsing this forum: No registered users and 2 guests

cron