Posts

Showing posts with the label Sort multiple SAS datasets using single Proc sort and CALL Execute

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

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 .||...