You seemed to have skipped explaining a lot of the steps here.
If you have macro variables that exist and you want to retrieve their values you can either just reference them.
my_ds_variable = "&my_macro_variable";
Or you could use SYMGET() function. Which would work better for a lot of macro variables since the name could come from an expression.
length mvar $32 value $200;
do 1=1 to 3;
mvar=cats('wtcalc',i);
value = symget(mvar);
output;
end;
Or just just reference SASHELP.VMACRO.
set sashelp.vmacro;
where name=: 'WTCALC' ;
If you really want to generate that strange macro variable you could do it like this (as long as the macro values do not exceed 200 bytes).
proc sql noprint;
select catx('=',name,value) into :logicx separated by ';%let '
from dictionary.macros
where name eqt 'WTCALC'
;
quit;
%let logicx=%nrstr(%let )%superq(logicx)%str(;) ;
If they do then perhaps use a data step instead so you can use SYMGET() to get the full value.
data _null_;
length logicx $4000 ;
retain logicx;
set sashelp.vmacro end=eof;
where name =: 'WTCALC' and offset=0;
logicx=cats(logicx,catx(' ','%let',name),'=',symget(name),';');
if eof then call symputx('logicx',logicx);
run;
%let logicx=%superq(logicx);
But why put this into a macro variable if the goal is to put it into data??
... View more