Hey!
I just started an internship and I have to code on SAS. But I have two problems that i didn't heard about on the internet and may be connected to my company network when I try to launch that test script:
DATA WORK.test;
INFILE "C:\Users\Documents\test.txt";
INPUT Column1 Column2;
RUN;
The first one is that error:
ERROR: Physical file does not exist, /opt/sas/config/Lev1/SASApp/C:\Users\Documents\test.txt.
I don't know why the root "/opt/sas/config/Lev1/SASApp/" is there and am I the only one to have that error? I didn't saw it anywhere.
So I have been told to put an 'n' after the path (nobody knows why) just like that:
DATA WORK.test;
INFILE "C:\Users\Documents\test.txt"n;
INPUT Column1 Column2;
RUN;
And now the error is:
ERROR 22-322: Syntax error, expecting one of the following: String, Quoted Chain.
ERROR 200-322: The symbol is not recognized and will be ignored.
What's wrong with the code?
I would really appreciate someone to help me with that case because I'm block if I can't even import a table.
Thanks a lot.
Have a good day!
PS: I'm on 7.1 Version
Your SAS ... most likely SAS Studio ... is running on a server and it cannot access files on your computer's C: drive. The file has to be uploaded to the server first, and then accessed via the proper INFILE statement using the server location of the file.
Something like this:
infile "/opt/sas/config/Lev1/SASApp/test.txt";
but of course, you must use the exact server folder name and what I gave in the example may not be right.
Your SAS ... most likely SAS Studio ... is running on a server and it cannot access files on your computer's C: drive. The file has to be uploaded to the server first, and then accessed via the proper INFILE statement using the server location of the file.
Something like this:
infile "/opt/sas/config/Lev1/SASApp/test.txt";
but of course, you must use the exact server folder name and what I gave in the example may not be right.
First thanks,
But, just by importing CSV files (File>New>Data>...) I can access to my computer's C: drive. Why can I reach it out in that case ?
Thanks
@jon8 wrote:
And also why in the second case have I a Syntax Error ?
Thanks a lot
Second case is not valid syntax. You can't use anything that looks like
infile "C:\Users\Documents...
and get it to work from SAS on a server.
@jon8 wrote:
First thanks,
But, just by importing CSV files (File>New>Data>...) I can access to my computer's C: drive. Why can I reach it out in that case ?
Ok, first let's establish what SAS interface are you using. Are you using SAS Studio, or something else? If you're not sure, show us a screen capture (click on the "Insert Photos" icon, do not attach files).
Repeating: click on the "Insert Photos" icon
You did not click on the "Insert Photos" icon.
I never download attachments, so please click on the "Insert Photos" icon.
Thanks. I am not all that familiar with how Enterprise Guide interacts with your Windows file system. I think others (perhaps @ChrisHemedinger ) can give a better explanation.
While SAS Enterprise Guide runs on your local Windows machine, your SAS session is remote (on Linux, most likely) and cannot "see" your local C: drive. So you cannot use SAS syntax to reach your local files on your C drive.
Instead, you must place the data file in a location where your SAS session can read it. For some users that might be on a shared network location that can be accessed by both Windows and Linux -- if you're lucky to have a setup like that in your org. We do here. For example:
If you don't have that, you can use the Copy Files task in SAS Enterprise Guide to copy the local data file from SAS to a known location on your remote SAS session. That step can be captured as part of your process flow in a project. I have a video tutorial for this here.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.