Learning SAS? Welcome to the exclusive online community for all SAS learners.

Base sas

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Base sas

Hi,

 

When i cope and paste this code to sas studio on my laptop (mac) I get an error, 

infile "&path/sales.csv" dlm=',';
input Employee_ID First_Name $

 

and here is the error I get, 

WARNING: Apparent symbolic reference PATH not resolved.
WARNING: Apparent symbolic reference PATH not resolved.
64 input Employee_ID First_Name $
65 Last_Name $ Gender $ Salary
66 Job_Title $ Country $;
67 run;
 
ERROR: Physical file does not exist, /opt/sasinside/SASConfig/Lev1/SASApp/&path/sales.csv.
 
I will appreciate if someone help and fix this problem.

Accepted Solutions
Solution
a month ago
SAS Super FREQ
Posts: 8,782

Re: Base sas

[ Edited ]

Hi:
As Reeza suggested, back in the Course Overview section, remember when there were 2 statements that we recommended you save as SETUP.SAS? One of the statements was a %LET statement and the other was a LIBNAME statement.

The %LET statement creates a "helper" macro variable called &PATH. So if you have:
%let path=/folders/myfolders/ecprg193;

then your INFILE statement would tell SAS (probably in SAS University Edition on a Virtual Machine) to
substitute the &PATH stored value in the INFILE statement:
infile "&path/sales.csv" dlm=',';
would become:
infile "/folders/myfolders/ecprg193/sales.csv" dlm=',';

or
%let path=/home/userID/ecprg193;
would essentially tell SAS to look here:
infile "/home/userID/ecprg193/sales.csv" dlm=',';

You can ALWAYS look in your ecprg193 folder, assuming you used the name we suggested you use. Then find the SALES.CSV file and right click on it and select Properties. The properties window should show you the correct folder path name.

If you did not put the %LET statement into your setup.sas program, then this would be a good time to revisit the course instructions and make sure that you create &PATH before you run your INFILE statement.

If you do NOT have SALES.CSV in your ECPRG193 folder, then that implies that your program in the very beginning of the class did not work correctly. You can always repeat the steps in the Course Overview section.

cynthia

View solution in original post


All Replies
Trusted Advisor
Posts: 1,444

Re: Base sas

Preceed your data step with defining where (what is the path) is your file located.

Do it by or a like:

    %let path = c:\mydata;  /* in windows  - or by */

    %let path = /home/user/mydata;   /* in unix/linux */

Super User
Posts: 18,603

Re: Base sas

In the instructions there's a step on setting up a macro variable path. Make sure to run that code and include it as well.

 

I think it has you set it up as part of the autoexec but it appears as if the autoexec behaviour has changed slightly since the course notes were modified and that doesn't work anymore,

Occasional Contributor
Posts: 5

Re: Base sas

Thank you, I will double check. 

Super User
Posts: 7,124

Re: Base sas

I moved the post to the SAS Analytics U forum, as I guessed from the contents it belongs here.

Please use more descriptive subject lines in the future; this is the SAS forum, so "Base SAS" tells people nothing.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 5

Re: Base sas

Thank you, the question is from lession 8, sas proggramming 1,essential. 

Solution
a month ago
SAS Super FREQ
Posts: 8,782

Re: Base sas

[ Edited ]

Hi:
As Reeza suggested, back in the Course Overview section, remember when there were 2 statements that we recommended you save as SETUP.SAS? One of the statements was a %LET statement and the other was a LIBNAME statement.

The %LET statement creates a "helper" macro variable called &PATH. So if you have:
%let path=/folders/myfolders/ecprg193;

then your INFILE statement would tell SAS (probably in SAS University Edition on a Virtual Machine) to
substitute the &PATH stored value in the INFILE statement:
infile "&path/sales.csv" dlm=',';
would become:
infile "/folders/myfolders/ecprg193/sales.csv" dlm=',';

or
%let path=/home/userID/ecprg193;
would essentially tell SAS to look here:
infile "/home/userID/ecprg193/sales.csv" dlm=',';

You can ALWAYS look in your ecprg193 folder, assuming you used the name we suggested you use. Then find the SALES.CSV file and right click on it and select Properties. The properties window should show you the correct folder path name.

If you did not put the %LET statement into your setup.sas program, then this would be a good time to revisit the course instructions and make sure that you create &PATH before you run your INFILE statement.

If you do NOT have SALES.CSV in your ECPRG193 folder, then that implies that your program in the very beginning of the class did not work correctly. You can always repeat the steps in the Course Overview section.

cynthia

Super User
Posts: 18,603

Re: Base sas

@Cynthia_sas it's looking like SAS UE is 'flushing' the PATH variable from the AUTOEXEC. It runs and creates the library but is not available afterwards in code. Not sure if a SAS UE change brought this about or it's always been this way. I don't know if it's the instructions or me or someone else who's been recommending that those lines be added in the AUTOEXEC as part of the set up procedures.

 

Other macro variables created hold their value but not the keyword PATH. 

 

I think @Shmuel first noted this behaviour.

Occasional Contributor
Posts: 5

Re: Base sas

[ Edited ]

Thank you very much Cynthia_SAS, Reeza, shmuel and Kurtbremser for your reply. 

Cynthia, I followed the steps again and it is fixed now. Just amazing answer!

I defined it once before as I remember, but I runed the code again and everything great. 

☑ This topic is solved.

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

Discussion stats
  • 8 replies
  • 423 views
  • 4 likes
  • 5 in conversation