data _null_; set sashelp.stocks; call symput ("nofobs", _n_); run; What if sashelp.stocks is 100M records? You're going to call symput() 100M times, overwriting nofobs 100M times, only to save the last result. That is, ahem, "inefficient". Number of observations != empty/not empty. Have a look at https://github.com/scottbass/SAS/blob/master/Macro/nobs.sas or https://github.com/scottbass/SAS/blob/master/Macro/check_if_empty.sas /*once those three text file done, want to touch empty 3 file */ /*some logic */ Why do you need to create three marker files? If this is just to control downstream processing, then isn't one marker file enough? Are the marker files meant to be the same name as your exported files? If so, of course create them before your export, otherwise they will overwrite your exported SAS files. FWIW, I usually implemented the logic: If marker file exists then ETL is running, don't run downstream code. If marker file does not exist then upstream ETL was successful, run downstream code. I then create the "ETL is running" marker file at the beginning of the ETL, and delete the marker file when the success condition is met. The downstream ETL loops while the marker file exists. Then if I come in the morning and the marker file exists I know where the error occurred. Of course, the email tells me that too :). I then fix the issue, manually delete the marker file, then re-run the downstream ETL. Finally, you might be able to steal some of the logic in here: https://github.com/scottbass/SAS/blob/master/Macro/lock.sas https://github.com/scottbass/SAS/blob/master/Macro/marker.sas It's not exactly what you're looking for but may give you some ideas...
... View more