data _null_;
call execute("Proc sql;");
do age=11 to 15;
call execute("title 'Students with age less than or equal to "||strip(age)||"';");
call execute("select * from sashelp.class where age le "||strip(age)||";");
end;
call execute("quit;");
run;
可以通过 call execute 实现:
例如:
data _null_;
set A;
this_date = effect_date;
call execute("proc sql;");
call execute("create table temp1 as select * from TABLE1 a where a.effect_date"||
" = (select max(b.effect_date) from TABLE1 b where b.effect_date<=" ||this_date||");");
call execute("create table temp2 as select * from TABLE2 a where a.effect_date "||
" = (select max(b.effect_date) from TABLE2 b where b.effect_date<=" ||this_date||");");
call execute("create table temp3 as select b.code, a.weight as weight1, b.weight as weight2"||
" from temp2 b full join temp1 a on a.code=b.code;");
call execute("quit;");
call execute("data temp3; set temp3; effect_date ="||this_date||"; run;");
call execute("proc append out=compare data = temp3;run;");
run;