SAS--Proc Contents

advertisement
UNC-Wilmington
Department of Economics and Finance
ECN 377
Dr. Chris Dumas
SAS--Proc Contents
Proc Contents--Summarizes Information about a Dataset that Has Been Imported into SAS
Often, when someone sends you a dataset, they don’t tell you (because they are busy, or it’s not their job to tell
you, or they have forgotten, or someone else created the dataset but they don’t work there anymore or they died,
etc.) summary information about the dataset, such as:




the number of variables in the dataset,
the variable names,
whether a particular variable has text or numeric values,
or the number of rows of data in the dataset.
Not having this summary information can be very frustrating. The Proc Contents command provides this
summary information for a dataset. This can be very useful.
The Proc Contents command is usually placed in a SAS program immediately following a Proc Import command
in order to summarize the dataset that has just been imported into SAS by the Proc Import command.
The Proc Contents command is very simple. In the example program in the box below, we inport a dataset named
“CountyData.xls” (we created this dataset in Homework 01) into SAS and give it the name “dataset01.” Then we
run Proc Contents on dataset01 to find out what’s inside dataset01. If you have already created dataset
CountyData.xls, and it is sitting in the ECN377 folder on your V: drive, then you can run the program below in
SAS.
/* SAS program name: ProcContents.sas */
/* Date: August 27, 2015 */
/* Programmer: Chris Dumas dumasc@uncw.edu */
options
options
options
options
helpbrowser=sas;
number pageno=1 nodate nolabel font="SAS Monospace" 10;
leftmargin=1.00 in rightmargin=1.00 in;
topmargin=1.00 in bottommargin=1.00 in;
proc import datafile="v:\ECN377\CountyData.xls"
run;
dbms=xls out=dataset01 replace;
proc contents data=dataset01;
run;
Note that the Proc Contents command in a SAS program is usually followed by a “Data step” or other “Proc”
commands that do various types of data analysis, but we are keeping it simple here and limiting the program to
just proc import and proc contents.
The results from Proc Contents would appear in Output window in SAS.
For convenience, the results of Proc Contents are presented below.
1
UNC-Wilmington
Department of Economics and Finance
ECN 377
Dr. Chris Dumas
Some especially useful items in the output from Proc Contents are highlighted in yellow. Note that the dataset
name (Dataset01) is shown, along with the number of observations (rows of data), 100, and the number of
variables, 4, in the dataset.
Also, the “Alphabetic List of Variables and Attributes” lists the variable names in alphabetical order, the type of
each variable (whether numeric or character), and the column number (#) where the variable is found in the
dataset (in the example below, the variable “TotalExp,” for example, would be found in column 3 of dataset01).
The SAS System
1
The CONTENTS Procedure
Data Set Name
Member Type
Engine
Created
WORK.DATASET01
DATA
V9
Sunday, August 23,
2015 04:51:18 PM
Sunday, August 23,
2015 04:51:18 PM
Last Modified
Protection
Data Set Type
Label
Data Representation
Encoding
Observations
Variables
Indexes
Observation Length
100
4
0
48
Deleted Observations
0
Compressed
Sorted
NO
NO
WINDOWS_64
wlatin1 Western (Windows)
Engine/Host Dependent Information
Data Set Page Size
Number of Data Set Pages
First Data Page
Max Obs per Page
Obs in First Data Page
Number of Data Set Repairs
Filename
Release Created
Host Created
4096
2
1
84
54
0
C:\DOCUME~1\dumasc\LOCALS~1\Temp\6e\SAS Temporary
Files\_TD14200\dataset01.sas7bdat
9.0202M2
X64_ESRV
Alphabetic List of Variables and Attributes
#
Variable
Type
Len
1
4
3
2
CntyName
PopCens
TotalExp
Year
Char
Num
Num
Num
19
8
8
8
Format
Informat
$19.
BEST12.
BEST12.
BEST12.
$19.
2
Download