BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MaryA_Marion
Lapis Lazuli | Level 10

hypertension exists. SAS Studio can't find it? WHy?


libname mylib '/home/u50158717/Stat.775.data';
filename hyperten 'hypertension.txt';
data hp;
infile "mylib.hyperten" DLM='09'X DSD TRUNCOVER;
input group $ NaCl;
run;

error messge in log

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

You need to include the complete path to the file in the filename statement. If you see the file in your file list, right-click and check the Properties, and copy the path from there, then add to your code:

 

filename hyper '/u/myfolder/hypertension.txt';

 

Then use the fileref in your INFILE:

infile hyper DLM='09'X DSD TRUNCOVER;

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

View solution in original post

5 REPLIES 5
ChrisHemedinger
Community Manager

You need to include the complete path to the file in the filename statement. If you see the file in your file list, right-click and check the Properties, and copy the path from there, then add to your code:

 

filename hyper '/u/myfolder/hypertension.txt';

 

Then use the fileref in your INFILE:

infile hyper DLM='09'X DSD TRUNCOVER;

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
Tom
Super User Tom
Super User

So your code has a LIBNAME statement and a FILENAME statement at the top, but your data step is not using either the libref (MYLIB) or the fileref (HYPERTEN) they defined.  Instead you are looking for a file named 'mylib.hyperten' in the current working directory.

 

If you want to use the libref then use it in specifying the output dataset name in the DATA statement.

data mylib.hp;

If you want to use the fileref then either point it to the actual file you want and then reference the fileref in your INFILE statement. So perhaps something like:

filename hyperten '/home/u50158717/Stat.775.data/hypertension.txt';
....
infile hyperten DLM='09'X DSD TRUNCOVER;

Or you could point the fileref to a folder and then name the specific file from that folder in the INFILE statement.

filename hyperten '/home/u50158717/Stat.775.data/';
....
infile hyperten('hypertension.txt') DLM='09'X DSD TRUNCOVER;

Or skip the FILENAME statement completely and just list the full filename in the INFILE statement.

infile '/home/u50158717/Stat.775.data/hypertension.txt' DLM='09'X DSD TRUNCOVER;
MaryA_Marion
Lapis Lazuli | Level 10
Two good explanations today. Thanks. I need to study your solution.
Reeza
Super User
You're mixing and matching concepts here.
Libraries are for referencing SAS data sets not text files. Filename is correct for text files but you have to provide the full path.
MaryA_Marion
Lapis Lazuli | Level 10
I keep thinking that with the libname location specified that the filename will be automatically be placed in mylib. Thank you. MM

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1268 views
  • 2 likes
  • 4 in conversation