This script defines the `%listvar` macro which accepts a dataset name as a parameter. It uses the `CONTENTS` procedure to extract metadata (name, variable number, table name, label) into an output table (named after the input table with the suffix 'names'). Then, it sorts this results table by the variable creation order (`varnum`).
Data Analysis
Type : CREATION_INTERNE
The script is a macro definition that generates a metadata table based on the table name passed as an argument.
1 Code Block
MACRO Data
Explanation : Definition of the `listvar` macro. It executes `PROC CONTENTS` to generate an output table containing the names and positions of the variables from the `&dataset` table, then sorts this resulting table by the `varnum` variable.
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.
Copyright Info : adopted from https://chemicalstatistician.wordpress.com/2015/01/06/get-a-list-of-the-variable-names-of-a-sas-data-set/
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.