Our tutorials reference a dataset called "sample" in many examples. If you'd like to download the sample dataset to work through the examples, choose one of the files below:
The CONTENTS procedure generates summary information about the contents of a dataset, including:
This procedure is especially useful if you have imported your data from a file and want to check that your variables have been read correctly, and have the appropriate variable type and format. (For example, you may wish to check that none of your character variables have been truncated, and that your date variables have not been misread.) The basic syntax of PROC CONTENTS
is:
PROC CONTENTS DATA=sample;
RUN;
As with all SAS procedures, the DATA
command (which specifies the name of the dataset) is optional, but recommended. If you do not specify a dataset, SAS will use the most recently created dataset by default.
Note that PROC CONTENTS will list the variables in alphabetical order, rather than the order they appear in the dataset. You can change this by adding the ORDER=VARNUM
option to the PROC CONTENTS statement:
PROC CONTENTS DATA=sample ORDER=varnum;
RUN;
The screenshot below shows the output of PROC CONTENTS on the sample data file. Key elements are labeled and described below the screenshot.
A The number of observations (or rows) in the dataset. Here, the sample dataset contains 435 observations.
B The number of variables (or columns) in the dataset. Here, the sample dataset contains 23 variables.
C The date and time that the dataset was created and last modified.
D This part of the output lists the dataset’s variables and their attributes.