Learning SAS? Welcome to the exclusive online community for all SAS learners.

Problem reading in data files

Reply
N/A
Posts: 1

Problem reading in data files

I am having issues importing a dataset into SAS.

I am currently using the University Edition (Operating System Red Hat 64 bit).

I am entering the following code:

/** FOR CSV Files uploaded from Windows **/

FILENAME CSV "/folders/myfolders/DRTB/tblMAIN_DRTB_DATABASE.csv" TERMSTR=CRLF;

/** Import the CSV file.  **/

PROC IMPORT DATAFILE=CSV

OUT=WORK.DRTB

DBMS=CSV

REPLACE;

RUN;

/** Print the results. **/

PROC PRINT DATA=WORK.DRTB; RUN;

/** Unassign the file reference.  **/

FILENAME CSV;

And the following error message keeps coming up:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

42 ;

43 PROC IMPORT DATAFILE=CSV

44 OUT=WORK.DRTB

45 DBMS=CSV

46 REPLACE;

47 RUN;

NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to

WORK.PARMS.PARMS.SLIST.

Unable to sample external file, no data in first 5 records.

ERROR: Import unsuccessful.  See SAS Log for details.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE IMPORT used (Total process time):

real time           0.03 seconds

cpu time            0.04 seconds

      

48

49 ;

50 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

60 ;

Please help. Thanks!

Super User
Posts: 10,516

Re: Problem reading in data files

Look at your input CSV file with a text editor and see if you have blank lines for the first 5 or more lines (exports from Excel are notorious for extra lines and columns). If they are blank, delete them and things should work.

The warning about the SASUSER.Parms. etc may mean that you had a SAS session open and created another instance. The SASUSER library catalogs would be locked by the first one. This often happens depending on your settings if you click on the code file to run it while a SAS session is open. The default behavior is to open another instance of SAS for the code file.

Super User
Posts: 9,682

Re: Problem reading in data files

PROC IMPORT DATAFILE=CSV

OUT=WORK.DRTB

DBMS=CSV

REPLACE;

guessingrow=32767;

RUN;

N/A
Posts: 1

Re: Problem reading in data files

Use this snippet, the other one doesn't work for me either

PROC IMPORT DATAFILE ='/folders/myfolders/spx.csv' OUT = mydata REPLACE;

RUN;

PROC PRINT DATA = mydata;      

TITLE 'My data';

RUN;

Super User
Super User
Posts: 6,502

Re: Problem reading in data files

If it is a CSV file then just write the Data step to read it yourself.  You will get better results than what PROC IMPORT would do since it will have to guess what types of values are in each column.

If you do not know what is in the file then you can use a DATA _NULL_ to read it and look at it. 

For example use the LIST statement and OBS=10 to list the first 10 lines.

data _null_ ;

  infile "/folders/myfolders/DRTB/tblMAIN_DRTB_DATABASE.csv" dsd OBS=10 TERMSTR=CRLF;

  input;

  list;

run;

Ask a Question
Discussion stats
  • 4 replies
  • 7424 views
  • 0 likes
  • 5 in conversation