Below is an example using count(*) in PROC SQL: %macro split(i, file); %do i=1 %to &i; proc sql noprint; select count(*) into :obs_count from &file._out&i; quit; %if &obs_count ne 0 and &file=res %then %do; proc export data=&file._out&i label /* The label option is used to export the label names as variable names */ outfile="&SF\covid19&file.&i..csv" dbms=csv replace; run; %end; %else %if &obs_count ne 0 %then %do; proc export data=&file._out&i outfile="&SF\covid19&file.&i..csv" dbms=csv replace; run; %end; %end; %mend split;
... View more