The macro operates on an existing SAS dataset whose name is passed as a parameter (`&dsn`). The specific origin of this dataset is not defined within the macro itself; it could be SASHELP data, data previously created in the session, or external data referenced via a libname.
1 Code Block
MACRO
Explanation : This block defines the `vdo_numvar` macro. It opens the dataset specified by the `dsn` parameter, uses the `attrn` function to retrieve the number of variables (`nvars`), and then closes the dataset. The direct result of the macro is the number of variables.
Copied!
macro vdo_numvar(dsn)/des="Nnmber of variables in a SAS dataset";
%let dsid=%sysfunc(open(&dsn));%sysfunc(attrn(&dsid,nvars)) %let rc=%sysfunc(close(&dsid));
%mend vdo_numvar;
1
macro vdo_numvar(dsn)/des="Nnmber of variables in a SAS dataset";
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.