BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
d6k5d3
Pyrite | Level 9

I am sorry for coming up with this most basic question. So far I have been working with Work library because of which I have not bothered about creating my own library. However, my recent codes take a long time to execute because of the volume of data, and each time I open SAS I need to run them all.

 

So my question is after creating my library by 

LIBNAME ZZZ 'mydata/myfile/...';

what should I do so that I don't need to write 'ZZZ' in my code over and over again. For example:

PROC IMPORT DATA= ZZZ.YYY...

Thus I will have reference ZZZ every time. I want to get rid of this referencing.

 

Much thanks. Regards.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The only library you do not need to reference is WORK. Anytime you use a one-level dataset name, it will automatically be assumed to be in WORK.

All other libraries have to be explicitly named.

If you want library names to be dynamic, you can use a macro variable, so you need to change the name in only one place in your code.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

The only library you do not need to reference is WORK. Anytime you use a one-level dataset name, it will automatically be assumed to be in WORK.

All other libraries have to be explicitly named.

If you want library names to be dynamic, you can use a macro variable, so you need to change the name in only one place in your code.

PaigeMiller
Diamond | Level 26

Your question and your example don't seem to fit together. 

 

To create a user defined library and have it available every single time you launch SAS, put the LIBNAME statement in your AUTOEXEC file.

 

However,

 

PROC IMPORT DATA= ZZZ.YYY...

is invalid syntax and does not fit with the title, because PROC IMPORT must point (with the DATAFILE= option, not the DATA= option which does not exist) to an actual file and not to a SAS data set, so a libname is not needed for this; you need an actual file name that DATAFILE= points to. You could use a macro variable here, said macro variable could be defined in your AUTOEXEC. 

--
Paige Miller
Ksharp
Super User
options user= 'mydata/myfile/...';


/*Then no need ZZZ. */

PROC IMPORT DATA= YYY...

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 798 views
  • 1 like
  • 4 in conversation