Iam using proc import procedure to import .txt file to SAS.
The text file is in my desktop. The following is the code.
proc import datafile="/Desktop/Sample.txt"
out=new_sample
dbms=dlm
replace;
guessingrows=2;
getnames=no;
run;
The log error is given below
ERROR: Import unsuccessful. See SAS Log for details.
Is there something wrong in the way I have imported the file??. Kindly support.
Hi,
Where is SAS actually executing?
And the search path to your file doesn't look like a desktop location.
As mentioned, a complete log would help.
Hello @vinsonros,
I'm guessing without seeing the full log that there is also a message in the Log stating ERROR: Physical file does not exist, \Desktop\Sample.txt. Here is a tip to help you locate the full path of the .txt file that is needed for the datafile= option.
Hi all,
Thanks for the reply.
Please find the attached log as requested.The following is the program run. This program run in Sas studio.
proc import datafile="C:/Users/acer/Desktop/Sample.txt"
out=vin_blanks4
dbms=dlm
replace;
guessingrows=2;
getnames=no;
run;
There is no need to attach text as FILES. Just paste into the pop-up window opened by the Insert Code icon.
ERROR: Physical file does not exist, /pbr/biconfig/940/Lev1/SASApp/C:/Users/acer/Desktop/Sample.txt.
The reason it did not work is that there is no file with that name on the machine where SAS is running.
It looks like you tried to ask SAS to find a file on your machine instead of one on the machine where SAS is running. Since the filename did not start with the root node Unix interpreted it as a relative file name so it looked for that a directory named C: under the current working directory that was in effect with SAS started.
Upload the file to your SAS machine first and then use a path in the SAS code that points to where you put the file.
This is your clue (as usual, the first error message is the most important):
ERROR: Physical file does not exist, /pbr/biconfig/940/Lev1/SASApp/C:/Users/acer/Desktop/Sample.txt.
You try to use a Windows path, while your SAS runs on a remote UNIX server.
Either upload the file to the server (both SAS Studio and Enterprise Guide can do this), or store it on a network share accessible both from your desktop and the SAS server.
If you use a licensed SAS install at your company/institution, get in touch with your SAS admins. If this happens on SAS On Demand, upload the file with SAS Studio and import from the upload location.
There is no need to use PROC IMPORT to read a simple file like that.
vineeth 85 35 Suceess Rosu 95 55 Failure Ryan 35 25 Sucess Sonny 45 21 Sucess
Just write the code yourself, you will do a MUCH better job than PROC IMPORT could.
data want;
infile '~/Sample.txt' truncover;
input name :$20. var1 var2 status :$10. ;
run;
Hi,
Thanks for the code.
I am in the learning stage now just would like to see whether proc import procedure is working in the system and why the error is being shown in the pgm.
Part of the learning process:)
why the error is being shown in the pgm
Hello!
As indicated already by the others: Your program cannot find the file under the path and name you have provided in the code.
When looking at the log message it seems that you try to use a windows path on a unix machine (where sas runs). That is, you need to make the file available to sas first and than use the filename under which sas sees the file.
In other words: You need to upload the file to the sas machine (or use some shared folders) so that you find it listed in SAS Studio. And the properties of _that_ file (again via SAS) reveal the path and filename you need to use in your in your program.
--fja
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.