I want to get observation number from expression <dsname(where=(...))> by using macro code. So I could write in any place (inside other procedure or %if statement) %if %sysfunc(nobs(dsname(where=(...)))) > 0 %then %do; BY-statement-code; %end; My current solution uses PROC FCMP and DOSUBL inside custom function NOBS. After all I use %sysfunc(NOBS(...)). Inside NOBS function I use NOBS ATTRN to obtain answer if possible. Otherwise, inside DOSUBL I use PROC SQL to count observation number. Is there any other universal solution, which more stable than NLOBSF? I think I could use FETCH inside NOBS function, but I don't know: should I extract WHERE= option and then apply something like If not where_string then delete; But there is a problem, that i can't in one function call extract where_string and use it as code. DOSUBL seems very hard for performance. It's intitializes additional environment/space/memory? Is there a way to do this elegantly and reliably?
... View more