BookmarkSubscribeRSS Feed
LymingHuang
Calcite | Level 5

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


SAS problem.PNG
13 REPLIES 13
AminB
Fluorite | Level 6

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;

Reeza
Super User

Try making sure to specify a DBMS, so SAS know what type of file it's trying to import

AminB
Fluorite | Level 6


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.

See:DBMS Identifiers Supported in Base SAS for more information about identifiers for this option.
LymingHuang
Calcite | Level 5

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

Reeza
Super User

1. restart UE

2. post code/ log from text version that failed.

ballardw
Super User

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)


LymingHuang
Calcite | Level 5

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

SAStestlog1.JPGSAStestlog2.JPG

Reeza
Super User

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;

Kurt_Bremser
Super User

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.

LymingHuang
Calcite | Level 5

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:

filename.JPG

and then the data step didn't work

data.JPG

Reeza
Super User

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.

LymingHuang
Calcite | Level 5

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

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 13 replies
  • 4239 views
  • 1 like
  • 5 in conversation