DATA Step, Macro, Functions and more

Storing a Macro variable.

Super Contributor
Posts: 276

Storing a Macro variable.

Hi Everyone..

I am Using  the following code..

Proc SQL;

select mail into : email separated by ' " " ' from dump;


filename report email from ="$$$$$$$$$@*******.com"


...So on..............................

My Question is ,instead of running the SQL Query Every time,I want to store that Email macro Variable permanently..

So ,Is there any way to store the macro variable permanently??

Posts: 7,366

Storing a Macro variable.

I've never heard of permanently storing a macro variable, but you could always wrap the code within a SAS macro (that you can store permanently), and then just call the macro whenever it is needed.  That would probably be a better choice, anyhow, as the email base is likely to change over time.

Super Contributor
Posts: 276

Storing a Macro variable.

Thank you art.

Respected Advisor
Posts: 3,124

Storing a Macro variable.

Or you could store it into a permanent text file, and put it back to a macro variable when needed:

%let email=%bquote("" "");

data _null_;

file "h:\email.txt";

put "&email";


data _null_;

infile "h:\email.txt" truncover;

input email $char50.;

put email;

if _n_=1 then call symputx('email_new',email);


%put &email_new;



Super User
Posts: 5,099

Storing a Macro variable.

It's already stored in a temporary data set.  You just need to retrieve it:

proc sql;

create table perm.macrovar as select * from dictionary.macros where name='MY_MACRO_VARIABLE';


However, if you are dealing with long values, dictionary.macros breaks up your variable into 200-character blocks which will need to be reassembled later.

Ask a Question
Discussion stats
  • 4 replies
  • 1 like
  • 4 in conversation