I'm trying a simple proc import:
proc import out = test datafile = "/folders/myfolders/cchs05.dta";
run;
Which gives me an error message saying 'physical file does not exist, '/folders/myfolders/cchs05.dta'.
I know I set up myfolders correctly because my libname statement
libname testlib "/folders/myfolders";
works fine.
And I saved 'cchs05.dta' to myfolders. In fact, I can see it from the SAS studio tab under my folders.
I've tried logging in and out. And using a data step but my infile statement gives a similar error.
Clearly, I'm missing something obvious but I really can't figure it out.
Any help would be greatly appreciated!
Thank you,
Lyming
Could it be that SAS does not recognize the .DTA file extension? The following example appears online. Maybe it can help you, specifically the DBMS and DELIMITER options. I am sorry but I have only imported CSV and EXCEL files into SAS.
proc import datafile='c:\temp\tab.txt'
out=class
dbms=dlm
replace;
delimiter='09'x;
datarow=5;
run;
Try making sure to specify a DBMS, so SAS know what type of file it's trying to import
Perhaps this narrative regarding DBMS might help:
DBMS=identifier
specifies the type of data to import. You can import JMP files (DBMS=JMP) or delimited files. To import a tab-delimited file, specify TAB as the identifier. To import any other delimited file that does not end in .CSV, specify DLM as the identifier. For a comma-separated file with a .CSV extension, DBMS= is optional. The IMPORT procedure recognizes .CSV as an extension for a comma-separated file.
Thanks for the suggestions but I don't think that's it...I think it's something more fundamental. I also have the data in .txt format but running a datastep with an infile statement gives the same error.
(Also, the SAS documentation seems to say '.dta' is not recognized as a DMBS identifier.)
1. restart UE
2. post code/ log from text version that failed.
You say this works fine:
libname testlib "/folders/myfolders";
Does this generate any error (test creating a data set)?
data testlib.test;
x=1;
output;
run;
(a basic test to see if you can write to that location)
Thanks again for the suggestions.
The test dataset worked for the library...but nothing else. I've included a log file below.
Here are the first 5 rows of a dataset in /folders/myfolders/
1 21213 293.76
1 38122 743.82
1 55113 2984.93
1 40111 975.96
1 40114 387.17
What happens with either of the following code:
proc import datafile='/folders/myfolders/cchs05.dta'
out=want
dbms=dlm
replace;
datarow=1;
delimiter='09'x;
run;
or
data want;
infile '/folders/myfolders/cchs05.dta' dlm='09'x truncover firstobs=1;
input ID MRN VALUE;
run;
do the following:
filename oscmd pipe "ls -l /folders/myfolders 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
This will write a complete directory listing of /folders/myfolders to the SAS log, including error messages if any happen (that is done by the 2>&1 redirection). You may get a clue out of that.
Thanks so much for the continued suggestions.
Reeza, I tried you two pieces of codes and both gave errors saying 'physical file does not exist'.
Kurt, the filename statement gave this:
and then the data step didn't work
After examine my install of SAS UE, I think SAS is correct and your file is located else where.
If I saved a file under folder/myfolders location it shows under the second myfolders in the image you've included. Yours does not.
You've created a folder shortcut with the same name, but it may not reference the same location.
Examine your Shared Folder and determine where folders/myfolders is set to. Check if the file is actually in that location.
That's it! I didn't set folders/myfolders correctly - I guess because it's case sensitive?
Anyway, it's working now. Thanks again for all the help!
Lyming
Keep in mind that SAS UE runs on an VM with Linux, and Linux, as any UNIX, is completely case sensitive.
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.
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.
Ready to level-up your skills? Choose your own adventure.