SAS Proc Contents – All about Proc Contents
sas proc contents, proc contents, sas proc contents example, proc contents options, sas proc contents options
Think of proc contents as your best friend. It is useful for a number of tasks, including to see if your data-set was read properly during the import process. For example, when you import a file, you may want to to check if the variables have been read correctly, and have the appropriate variable type and format. You might also want to see how many observations (rows) were read (or included in the import process). If you need to understand SAS Base fully, I have a full 5hr course available here SAS Base: Full, Discounted Price
What Info Does Proc Contents Give You?
Proc contents will give you information about type, length, format, informat and label of the variables in the data-set.
Type will tell you if a variable is numeric or character. Maybe you are trying to perform some statistics on a variable but you are getting errors. This might be a good opportunity to use proc contents. You might be getting this error because the variable is a character variable. This is much more likely if you used proc import to import your data-set. Remember, in SAS, you cannot do calculations with character variables. To perform the statistics, you will first need to convert the character variable to a numeric type. You can read about converting from a character variable to numeric here: https://mydatacareer.com/sascharactertonumeric/
Length will tell you how much space a variable takes up. The length of a character variable lines up in proportion to the number of characters..so “Eleanor” would be 7 characters. Numeric variables do not work in the same way. Length for numeric variables range from 3 to 8 bytes, with greater number of bytes representing an ever greater ability to represent larger integers with good precision. For example, a numeric length of 3 bytes means that an integer up to about 8,000 can be represented precisely. Therefore, if you have variables that do not use integers any higher than this, you can set the variables to a smaller length, allowing you to improve system performance.
An informat will tell you how a variable was read, while a format tells you how a variable will be displayed. If there is no information this, it means it is just a default.
Finally, a label is simply information that describes a variable. If you are not familiar with a data-set, and you see a variable name like RANK, you might not be sure what it is referring to. Label will usually specify what that variable name represents. It will say something like “rank of the police officer”.
The most basic syntax is straightforward:
proc contents data=nameofdataset;
Even the data option is optional, meaning, if you do not add the data option (the name of the data-set in question), it will run proc contents on the last created data-set.
There are many other options that you could potentially utilize. The DIRECTORY option prints a list of the SAS files in the SAS library. You could use the DETAILS option if you want to include information about the number of observations, number of variables, number of indexes, and data set labels. And finally, you can use the OUT= if you want to specify a name for the output data-set.
If you are stuck, or you simply need more information, proc contents can come to your rescue. If you have more questions, feel free to ask below by commenting!
Top Udemy Courses: