How to read data set downloaded to SAS 9.4?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 112
Accepted Solution

How to read data set downloaded to SAS 9.4?

Hello everyone,

 

I started to use SAS 9.4 few days ago.

I have some problems with the difference between dirdata, libname perm, and the external data sets which I downloaded in my computer (C drive).

 

The code I was using was:

%let dirdata=C:/Users/jc3992/Downloads;


* From week 4: ;
data expenses;
	infile "&dirdata.expensesArray.csv" 
		dlm="," DSD firstobs=2 termstr=CRLF;
	length ResortName $26 Resort $8;
	input ResortName Resort OffSeason1-OffSeason6;
run;

The LOG was as below:

1679  data expenses;
1680      infile "&dirdata.expensesArray.csv"
1681          dlm="," DSD firstobs=2 termstr=CRLF;
1682      length ResortName $26 Resort $8;
1683      input ResortName Resort OffSeason1-OffSeason6;
1684  run;

ERROR: Physical file does not exist, C:\Users\jc3992\DownloadsexpensesArray.csv.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.EXPENSES may be incomplete.  When this step was stopped there were 0
         observations and 8 variables.
WARNING: Data set WORK.EXPENSES was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

I did not know why it made sense to me that I had defined the path, but SAS could not read it in.

Had stuck in it several hours lol

I wonder if anyone would kindly help me out?

 

Thank you!! Any assistance would be appreciated!


Accepted Solutions
Solution
‎03-04-2018 09:09 PM
Valued Guide
Posts: 593

Re: How to read data set downloaded to SAS 9.4?

OK try this then

 

data expenses;
	infile "&dirdata/expensesArray.csv" 
		dlm="," DSD firstobs=2 termstr=CRLF;
	length ResortName $26 Resort $8;
	input ResortName Resort OffSeason1-OffSeason6;
run;

View solution in original post


All Replies
Valued Guide
Posts: 593

Re: How to read data set downloaded to SAS 9.4?

[ Edited ]

Try adding an extra dot in your infile statement after the macro variable like so

 

%let dirdata=C:/Users/jc3992/Downloads;


* From week 4: ;
data expenses;
	infile "&dirdata..expensesArray.csv" 
		dlm="," DSD firstobs=2 termstr=CRLF;
	length ResortName $26 Resort $8;
	input ResortName Resort OffSeason1-OffSeason6;
run;

The first dot will be consumed by the macro processor which is why it's not formulating your pathname/filename correctly

Frequent Contributor
Posts: 112

Re: How to read data set downloaded to SAS 9.4?

Posted in reply to ChrisBrooks
      Physical Name: C:\Users\jc3992\Downloads
1751  data expenses;
1752      infile "&dirdata..expensesArray.csv"
1753          dlm="," DSD firstobs=2 termstr=CRLF;
1754      length ResortName $26 Resort $8;
1755      input ResortName Resort OffSeason1-OffSeason6;
1756  run;

ERROR: Physical file does not exist, C:\Users\jc3992\Downloads.expensesArray.csv.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.EXPENSES may be incomplete.  When this step was stopped there were 0
         observations and 8 variables.
WARNING: Data set WORK.EXPENSES was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

Thanks but....it did not work still...

 

Solution
‎03-04-2018 09:09 PM
Valued Guide
Posts: 593

Re: How to read data set downloaded to SAS 9.4?

OK try this then

 

data expenses;
	infile "&dirdata/expensesArray.csv" 
		dlm="," DSD firstobs=2 termstr=CRLF;
	length ResortName $26 Resort $8;
	input ResortName Resort OffSeason1-OffSeason6;
run;
Frequent Contributor
Posts: 112

Re: How to read data set downloaded to SAS 9.4?

Posted in reply to ChrisBrooks
%let dirdata=C:/Users/jc3992/Downloads;
data expenses;
	infile "&dirdata/expensesArray.csv" 
		dlm="," DSD firstobs=2 termstr=CRLF;
	length ResortName $26 Resort $8;
	input ResortName Resort OffSeason1-OffSeason6;
run;

Finally....

it worked  Q___Q

I can go home for dinner lol

 

Thanks!!!!

Frequent Contributor
Posts: 112

Re: How to read data set downloaded to SAS 9.4?

But why would this become like this ?

Super User
Posts: 23,724

Re: How to read data set downloaded to SAS 9.4?


jc3992 wrote:

But why would this become like this ?


Attention to detail. You probably had the / in the DirData before or in the path.

If you're just starting out, I don't recommend using macro variables at the beginning. List your paths out fully, understand the basics and extend out from there. 

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 146 views
  • 2 likes
  • 3 in conversation