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 seconds
Thanks 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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.