thomas-rasmussen / sas_macros

SAS macros
Creative Commons Zero v1.0 Universal
5 stars 4 forks source link

hash_match: inefficient counting of rows in dataset #64

Open thomas-rasmussen opened 1 year ago

thomas-rasmussen commented 1 year ago

The following SQL step using count() to find the number of rows in datasets is inefficient. https://github.com/thomas-rasmussen/sas_macros/blob/946b8b376f62ed4a8b3583dccb58a960a808c3b1/hash_match.sas#L817-L825 Replace with an approach that pulls the information from metadata.

Look at other code or maybe https://www.listendata.com/2017/04/number-of-observations-in-sas-data.html for inspiration

thomas-rasmussen commented 1 year ago

Maybe something like

%local ds_id rc n_rows; %let ds_id = %sysfunc(open(data)); %let n_rows %sysfunc(attrn(&ds_id, nobs)); %let rc = %sysfunc(close(&ds_id));