BookmarkSubscribeRSS Feed
axn9077
Calcite | Level 5

I have two libname statements in the attached code (I only run 1 at a time) that should be the same yet only one works. The direct call-out works but using the macro variable name does not. From what I can tell, these are the EXACT SAME things. When I run the libname using dirSAS  I receive an error. Please advise.

 

Code: 

%let dirLSB=/folders/myshortcuts/MyRawData;
%let dirSAS=/folders/myfolders;

 

*libname libsas 'dirSAS'; *This does not work;
libname libsas '/folders/myfolders'; *This does work;

 

data libsas.Snow1;
infile "&dirLSB/Pr1Snowfall1.csv"
DLM =','; *Range of, comma delim;
input Season $ Sep Oct Nov Dec Jan Feb Mar Apr May Total;
RUN;

 

Error:

NOTE: Library LIBSAS does not exist.

1 REPLY 1
arodriguez
Lapis Lazuli | Level 10

You have put your directory in a macro variable. Using

libname libsas 'dirSAS';

You are trying to create a libname called libsas of the directory dirSAS(that doesn't exist). To replace the content of a macro variable you must use & before the name of the variable. Furthermore simple quote doesn't allow macro replacement, you must use double quotation marks

libname libsas "&dirSAS";

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 1 reply
  • 664 views
  • 1 like
  • 2 in conversation