Hello Guys,
Can anyone tell me is there any way to store the macro variable permanently so that it will exist across all upcoming SAS session too, I read about STORE option and AUTOCALL library but those things for macro code, is that applicable for storing macro variable??
Any way to storing and updating macro variable across the session?
Put the data in a dataset. Simply put macro is not a system for storing or processing data. It is a find/replace system for generating text, and only that.
Base SAS which insludes the full programming language, types, datasets and such like, is for storing and processing data.
Use the right tool for the right job.
If it is a parameter, which needs to be available at system startup, then you create that parameter in the autoexec.sas file. But that is not the system to use for storage of data.
What do you want to control with that macro variable?
The only way to directly get a macro variable into a session is to set it in one of the autoexec resources, and you DO NOT DO THAT dynamically.
Instead, write it to a dataset every time you leave a session:
data sasuser.macrovars;
length
name $32
value $64
;
input name;
value = symget(name);
cards;
prevtime
;
run;
And you can now add static(!) code to your autoexec:
data _null_;
set sasuser.macrovars;
call symput(name,value);
run;
Instead of sasuser, use any permanent library you have.
You can add the first code in your EG as code to be submitted after each task and SAS Code, and the second as code being sent when a server connection is established.
"Since we cant refer the variable from different dataset" - why can't you? There is merging/joining, formats, lookups etc.
proc sql; create table a as select * from new where start_time <> (select start_time from libr.old); quit;
Replaces the two steps you show.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: