BookmarkSubscribeRSS Feed
vinsonros
Fluorite | Level 6

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.

 

 

9 REPLIES 9
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10
Good Morning ... could you provide the log file, pls (as indicated)? And maybe the first couple of lines of your input file ...
--fja
LinusH
Tourmaline | Level 20

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.

Data never sleeps
D_Dunlap
SAS Employee

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.

  1. Locate the file on the Desktop
  2. Right click the file.
  3. Select Properties
  4. Copy and paste the value in the Location: field in the Properties window for the file into the datafile="Copy-paste-location-here/Sample.txt"  option.
  5. Try submitting the code again.  
vinsonros
Fluorite | Level 6

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;

 

 

 

Tom
Super User Tom
Super User

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.

Kurt_Bremser
Super User

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.

Tom
Super User Tom
Super User

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;
vinsonros
Fluorite | Level 6

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:)

 

 

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

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

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 9 replies
  • 2160 views
  • 5 likes
  • 6 in conversation