Professional Documents
Culture Documents
TITLE; FOOTNOTE;
Do Hands On Exercise P 114
6
CUSTOMIZING TITLES AND FOOTNOTES
There are a number of options that can be used with the
TITLE or FOOTNOTE statements to customize the look of
your title.
Some of these options include specifying color with a C=
or COLOR= option. For example:
*This is a message
It can be several lines long
But it always ends with an ;
*************************************************************
* Boxed messages stand out more, still end in a semicolon *
*************************************************************;
DATA MYDATA; * You can put a comment on a line of code;
PROC PRINT;
PROC MEANS;
RUN;
Another boundary statement is the QUIT statement. It is
sometimes used in conjunction with a RUN statement to cease
an active procedure. For example:
PROC REG;
RUN;
QUIT;
12 SAS ESSENTIALS -- Elliott & Woodward
5.2 UNDERSTANDING PROC STATEMENT SYNTAX
Although there are scores of SAS PROCs (procedures), the
syntax is consistent across all of them. The general syntax
of the SAS PROC statement is:
The name of
the SAS OPTIONS appear STATEMENTS Statements may
procedure BEFORE the appear as a have their own
such as semicolon. Typical separate “phrase” options following
MEANS or options are DATA=, (with its on a slash (/).
PRINT. NOPRINT, and others semicolon.) These
– typically deal with usually specify
the data set or options within the
output. procedure. There
may be multiple
Statements.
PROC MEANS
DATA=“C:\SASDATA\SOMEDATA”
MAXDEC=2;
RUN; Notice that BOTH the DATA= and
the MAXDEC= options are within
the first semicolon.
VAR varlist;
An example is as follows:
PROC MEANS;
VAR HEIGHT WEIGHT AGE;
RUN;
VAR Q1-Q50;
Sort
PROC SORT DATA="C:\SASDATA\SOMEDATA"
OUT=SORTED;
Note OUT= in OPTIONS
BY GP;RUN;
PROC MEANS DATA=SORTED MAXDEC=2;
BY GP;
BY is used first to SORT,
RUN; then to request analysis
by group.
GP is the BY variable…
thus multiple analyses
BY GP
EXERCISE – Change the BY value to STATUS instead of GP (Sort first). Rerun the analysis.
PAUSE. Continue once you have completed this exercise
28
5.3 USING THE ID STATEMENT IN A SAS PROCEDURE
The ID statement provides you with a way to increase the
readability of your output. It instructs SAS to use the
specified variable as an observation identifier in a listing
of the data (Instead of the OBS column.)
* FIRST VERSION;
PROC PRINT DATA=MYSASLIB.SOMEDATA;RUN;
* SECOND VERSION;
PROC PRINT DATA=MYSASLIB.SOMEDATA;
ID RAT_ID;
RUN; RAT_ID is the ID variable
WHERE TRT="A";
WHERE STATUS LT 4;
35
Do Hands On Example p 125
Example of the WHERE statement
WHERE TRT="A";
RUN;
SUM COST;
In this code, SAS splits the labels where it sees an asterisk. Do the
Hands On Example p 129 (APRINT3.SAS).
These slides are provided for you to use to teach SAS using this book. Feel free to
modify them for your own needs. Please send comments about errors in the slides
(or suggestions for improvements) to acelliott@smu.edu. Thanks.