Tom:
Thanks a huge. It indeed works. But how to save out the result on each call(the results are diff. but I can only save out the last call result).
/* pass coln as para
call macro within dataset*/
data ds_para;
input ind indst indend sign;
datalines;
1 800 1100 -1
2 4000 5000 1
3 6000 7000 -1
4 7500 8500 1
5 9000 9500 -1
6 14000 15000 1
7 18000 20000 -1
8 20500 21500 1
9 22000 23000 -1
10 23000 24000 1
;run;quit;
data tempx;
do i=1 to 30000;
x=ranuni(0);
output;
end;
run;quit;
%global ReturnVar;
%macro test(ind, indst, indend, sign);
%if &sign=-1 %then %do;
proc sql noprint;
select i into: ReturnVar
from tempx
where i between &indst. and &indend.
having x=min(x);
quit;
%end;
%if &sign= 1 %then %do;
proc sql noprint;
select i into: ReturnVar
from tempx
where i between &indst. and &indend.
having x=max(x);
quit;
%end;
%put "ReturnVar=&ReturnVar.";
%mend;
/* works below: resolve() but only without "any" sas code
DOSUBL() if sas code
*/
data want ;
set ds_para ;
/*result=resolve(cats('%test(',catx(',',ind,indst,indend,sign),')'));*/
t=DOSUBL(cats('%test(',catx(',',ind,indst,indend,sign),')'));
res="&ReturnVar.";
result=put("&ReturnVar.",8.);
run;
... View more