When working with data, we frequently want to examine the names and attributes of variables present in a dataset.
We need programming features to achieve this. There are multiple ways of getting this result and usage of proc contents is one such approach.
Let us assume that we have been given a dataset named class to work with. We can check the list of variables present in the dataset by executing the code below.
proc contents data=class;
By default, proc contents produces multiple output objects. But in this context we are interested in the output object related to list of variables.
Below is the screenshot of the result produced by proc contents in the output window. The output includes the variable position in the dataset, name of the variable, type of the variable, length of variable and optionally other variable attributes like label, format and informat associated with the variables will be displayed.
If we are interested in storing the above result in an output dataset, we need to specify the name of the output dataset using out=option on the proc contents statement.
proc contents data=class out=cont01;