Reading and Generating CSV Files Using SAS Studio

Reply
Learner
Posts: 1

Reading and Generating CSV Files Using SAS Studio

I am novice to SAS.Though have seen same post earlier but didn't helped me.

 

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

FILENAME CSV "/folders/myfolders/Study1/wine.csv" TERMSTR=CRLF;

/** Import the CSV file. **/

PROC IMPORT DATAFILE=CSV
OUT=WORK.MYCSV
DBMS=CSV
REPLACE;
RUN;

/** Print the results. **/

PROC PRINT DATA=WORK.MYCSV; RUN;

/** Unassign the file reference. **/

FILENAME CSV;

 

 

According to me everything is same as in video tutorial explained but am getting error message

 

Please note: i am using the most recent version of virtualBox.


sas_error.JPG
SAS Super FREQ
Posts: 8,820

Re: Reading and Generating CSV Files Using SAS Studio

Hi:
The error message is telling you that WORK.MYCSV does not exist. So there must be some kind of error in your INPUT file. The note about SASUSER is not anything to worry about, but the OTHER note about "Unable to sample external file, no data in first 5 records." could be significant. If you look inside your CSV file with NOTEPAD, what do you see?

This Tech Support note: http://support.sas.com/kb/19/720.html may or may not be relevant, as it refers to an older version of SAS
and this user group paper:
https://support.sas.com/resources/papers/proceedings12/248-2012.pdf suggest possible workarounds. In addition, there have been some previous Forum postings like this one that were solved by various means: https://communities.sas.com/t5/SAS-Procedures/Problem-importing-my-CSV-into-SAS-University-Edition/t...

cynthia
Super User
Posts: 19,192

Re: Reading and Generating CSV Files Using SAS Studio

Try the following, also make sure that the case of the file is all lower case as Unix is case sensitive.

 

/** Import the CSV file. **/
PROC IMPORT DATAFILE="/folders/myfolders/Study1/wine.csv"
OUT=WORK.MYCSV
DBMS=CSV
REPLACE;
RUN;
/** Print the results. **/
PROC PRINT DATA=WORK.MYCSV; RUN;
Contributor
Posts: 20

Re: Reading and Generating CSV Files Using SAS Studio

I get the error shown in your attachment when I try to read a file with unix end of line characters, LF, with windows end of lines, CRLF.  I would try TERMSTR=LF in the filename.

 

Paul

Ask a Question
Discussion stats
  • 3 replies
  • 289 views
  • 0 likes
  • 4 in conversation