CALL EXECUTE: Easy way to print or sort multiple files.

This post was kindly contributed by StudySAS Blog - go there to comment and to read the full post.


When printing multiple files, or sorting multiple datasets, the traditional method is to write multiple steps as below.

Proc print data=libref.ae; var _all_; run;

Proc print data=libref.conmed; var _all_; run;

Proc print data=libref.demog; var _all_; run;

Proc print data=libref.lab; var _all_; run;

Proc print data=libref.medhist; var _all_; run;

If you are like me who likes to simplify the traditional SAS code here is the tip. CALL EXECUTE comes to rescue here.

*Using Disctionary Tables and Call Execute;

proc sql;

create table dsn as select distinct memname from dictionary.tables

where libname=”LIBREF” and memtype=”DATA”;

quit;

*Sorts all the datasets using Call Execute;

data _null_;

set dsn;

call execute (“proc sort data=final.||’memname||’;by usubjid; run;”);

run;

*Prints all the datasets using Call Execute;

data _null_;

set dsn;

call execute (“proc print data=final.||’trim(memname)||’;var _all_; run;”);

run;

*Using Proc Contents and Call…

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]

This post was kindly contributed by StudySAS Blog - go there to comment and to read the full post.