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!
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;
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
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 secondsThanks but....it did not work still...
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;
%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!!!!
But why would this become like this ?
@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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.