BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jc3992
Pyrite | Level 9

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

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

6 REPLIES 6
ChrisBrooks
Ammonite | Level 13

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

jc3992
Pyrite | Level 9
      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...

 

ChrisBrooks
Ammonite | Level 13

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;
jc3992
Pyrite | Level 9
%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!!!!

jc3992
Pyrite | Level 9

But why would this become like this ?

Reeza
Super User

@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. 

 

 

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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