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;

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

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;

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
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-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
  • 5 replies
  • 1666 views
  • 2 likes
  • 4 in conversation