Hello team,
I created a libname for a file which exists in SAS.
I get an error message that the libname doesn't exist.
Should I create a libname for a file which already exist in SAS?
Please advise me.
Regards,
Blue blue
I created a libname for a file which exists in SAS.
I get an error message that the libname doesn't exist.
Not sure what you mean here. If the file is already in SAS, it doesn't need a libname. (Libnames are for folders, not files) Please show us your code, and a screen capture that shows the file as it appears in SAS.
I created a libname for a file which exists in SAS.
I get an error message that the libname doesn't exist.
Not sure what you mean here. If the file is already in SAS, it doesn't need a libname. (Libnames are for folders, not files) Please show us your code, and a screen capture that shows the file as it appears in SAS.
Hello,
Yes, I misspelled the name of the folder.
I didn't know we shouldn't create a libname for a folder that already exist in SAS. Thanks for your input.
Anyway, it doesn't allow me to read from the file that already exists in SAS:
data mydata; set membertable (obs=100); Run;
The error I get is:
File work.membertable doesn't exist.
The folder is in SAS, but the backend is unix server.
Blue blue
@GN0001 wrote:
Hello,
Yes, I misspelled the name of the folder.
I didn't know we shouldn't create a libname for a folder that already exist in SAS. Thanks for your input.
Anyway, it doesn't allow me to read from the file that already exists in SAS:
data mydata; set membertable (obs=100); Run;The error I get is:
File work.membertable doesn't exist.
The folder is in SAS, but the backend is unix server.
Blue blue
What is the file you are trying to access? If you have a SAS datasets on disk you can either assign a libref that points to the directory that contains the file using a LIBNAME statement or LIBNAME() function and reference the file using a "two level" name. (Note if you already have a defined libref just use that libref)
libname mylib 'mydirectoryname';
data mydata;
set mylib.membertable (obs=100);
run;
Or just reference the file by using its physical name in quotes.
data mydata;
set "mydirectoryname/membertable" (obs=100);
run;
Note that SAS will silently make a libref pointing to the directory for you without telling you.
Hello,
Actually the data exists in SAS but without libname, I can't read from that dataset.
Regards,
Blue Blue
Not technically correct you can reference a file with the full path.
data want;
set '/home/fkhurshed/Demo1/class.sas7bdat';
run;
@GN0001 wrote:
Hello,
Actually the data exists in SAS but without libname, I can't read from that dataset.
Regards,
Blue Blue
Unless your want to use a libref engine that access many members in a single file (like XPORT or XLSX) then the libname should point to the folder that contains the file not the actual file that is the SAS dataset.
So if SAS is running on Unix and you have a file named mydata.sas7bdat in a directory named \home\myname\myfiles then your SAS code might look like:
libname XXX '\home\myname\myfiles';
proc contents data=xxx.mydata;
run;
Hello,
Still, I can't read the file if I don't create a libname statement. SAS is running on unix.
Regards,
blue blue
Please post the complete log of the LIBNAME statement.
@GN0001 wrote:
Hello team,
I created a libname for a file which exists in SAS.
I get an error message that the libname doesn't exist.
Should I create a libname for a file which already exist in SAS?
Please advise me.
Regards,
Blue blue
You did something wrong. Show your work if you want to know where specifically you went wrong.
one of the folders in the path in the libname is misspelled.
Instead of QA, I spelled AQ.
Thanks,
Blue Blue
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.