This macro determines the number of rows in a table. If no filter is specified, it delegates the counting to another macro named '%numobs'. If a filter is provided, it uses system functions (OPEN, ATTRN parameterized with 'NLOBSF', CLOSE) to obtain the number of logical observations respecting the condition, which is generally more performant than a DATA step or a SQL COUNT(*).
Data Analysis
Type : CREATION_INTERNE
The script only defines programming logic (macro) without accessing specific data during its compilation.
1 Code Block
MACRO
Explanation : Definition of the 'wherobs' macro. It checks if the 'mywhere' parameter is empty. If so, it calls '%numobs'. Otherwise, it opens the table via %sysfunc(open(...)) with the filter, retrieves the number of filtered observations via %sysfunc(attrn(..., nlobsf)), and closes the table.
%ELSE %put ERROR: Could not open dataset %upcase(&dsn).;
15
%mend wherobs;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.