BookmarkSubscribeRSS Feed
LFern
Obsidian | Level 7

My "step1.sas" holds all my libnames & %let variables. It's supposed to be a master archive of libnames and variables to be used in other subsequent sas programs.

 

Because I don't want a million libnames to be assigned automatically in my sas steps 2-10, Step1.sas also has a macro sql procedure that only assigns select libnames to certain steps. For example, if my step3.sas only needs a libname called "input7", then my step1.sas has the following:

 

%Let STEP3_PATHS=;

proc sql;

reset noprint;

select distinct "LIBNAME " || libname

into : STEP3_PATHS separated by ";"

from DICTIONARY.LIBNAMES

where libname not in

 

(

'LIST OF LIBNAMES TO KEEP or CANT BE CLEARED'

, 'WORK'

, 'SASUSER'

, 'SASHELP'

, 'MAPSSAS'

, 'MAPSGFK'

, 'MAPS'

 

, 'INPUT7'

)

;

 

------------------------------------------

And in my step3.sas, I call up step1.sas & step3-specific libnames with:

%include "C:\Users\myname\Step1.sas";

 

&STEP3_PATHS;

 

------------------------------------------

 

I want to be able to duplicate this libname sql for %let variables. I don't want a million %let variables to be assigned when I use %include "C:\Users\myname\Step1.sas";

 

Instead, when I run step3.sas, I only want a few relevant %let variables to be called up from step1.sas.

 

Any thoughts on how to accomplish this? Any help is appreciated.

1 REPLY 1
Astounding
PROC Star

Certainly you need a source of information that could reproduce any of the million macro variables.  I would suggest keeping it as a SAS data set with three variables:

 

  • Step  (the step that needs this macro variable)
  • Name  (the name of the macro variable)
  • Value  (the value to assign to this macro variable)

Then your step1.sas program could do something like this:

 

data _null_;

set source_of_information;

where step = "Step 1";

call symputx(name, value);

run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 1 reply
  • 306 views
  • 0 likes
  • 2 in conversation