Hello,
I am having a problem with refreshing macro variables using proc sql inside a macro program. I have tried to resolve this 3 different times before and have given up each time, but I need this to work. Here's my code:
%macro ILikeThisMacro;
do something;
proc sql noprint;
select count(distinct(name))
into :drv_cnt
from dictionary.columns
where memname = upcase("&forecast_input_data_set")
and varnum > 11;
select distinct name
into :drvs separated by " "
from dictionary.columns
where memname = upcase("&forecast_input_data_set")
and varnum > 11;
select distinct quote(trim(left(name)))
into :drvs_name separated by ","
from dictionary.columns
where memname = upcase("&forecast_input_data_set")
and varnum > 11;
quit;
data ldp.&forecast_input_data_set (drop= i);
set ldp.&forecast_input_data_set;
array driv_cols(&drv_cnt) &drvs;
array driv_list(&drv_cnt) $ _temporary_ (&drvs_name);
do i = 1 to &drv_cnt;
if find(forecast_drivers, driv_list(i)) < 1 then driv_cols(i) = 0;
end;
run;
do something;
%mend ILikeThisMacro;
data _null_;
set filelist;
call execute %ILikeThisMacro.....;
run;
Basically, I run the "ILikeThisMacro" for multiple files and each time the proc sql should refresh the following macro variables: &drv_cnt, &drvs, and &drvs_name.
However, it seems that the macro variables are being created at compile time and then those same values are being used for every instance of the "ILikeThisMacro".
When the proc sql is not enclosed inside a macro program and is run once, it works BEAUTIFULLY!
Any suggestions?
Thanks,
kdp
... View more