The source dataset is provided via the `libds` parameter. This can be a standard SASHELP dataset, or any other existing dataset in the SAS environment. The macro does not generate internal data (via DATALINES/CARDS) but operates on pre-existing data.
1 Code Block
MACRO Data
Explanation : This block defines the `%mp_distinctfmtvalues` macro. It initializes local variables to store the format (`fmt`) and type (`vtype`) of the input variable, using external macros `%mf_getvarformat` and `%mf_getvartype`. Then, a `PROC SQL` is used to create a new dataset (`&outds`). The `SELECT DISTINCT` statement ensures that only unique values are retained. Conditional logic with `%IF/%ELSE` applies the appropriate format to the variable (`&var`): if it's a character without a format, the variable is selected directly; if it's a character with a format, or a numeric with a format, the `PUT` function applies the format. For numerics without a format, `PUT(&var,32.)` is used as the default format. The output variable is named `&outvar` and its length is defined by `&varlen`.
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.