Sunteți pe pagina 1din 8

Categorize Variables Within PROC REPORT

Variables can be defined as one of the following:


Display (define staffid/display width=15;)
Order (define gender/order width=15 Gender;)
Group (define gender/group
width=15 'Gender';)
Analysis (define salary/analysis mean
width=15 'Average/Salary';)
Across (define gender/across
width=15 'Gender' center;)
Computed (define bonus/computed
width=15 format=dollar9.;
compute bonus;
bonus=salary*0.15;
endcomp;)
Categorize Variables Within PROC REPORT
DISPLAY show value as it is without manipulation.
ORDER order the records according to the formatted values. If there are multiple records
Having the same value for the order variables, only the first occurrence of each
value will be Displayed in the report.
GROUP to summarize data for each value of the group variable.
ANALYSIS must be numeric variable, so statistics can be generated. The default statistics
is TOTAL. Normally GROUP and ANALYSIS variables come together. That is, if a
variable is defined as GROUP variable, then a numeric variable will be defined as
ANALYSIS variable.
ACROSS each unique value for the across variable will become a column. The default
statistics for across variable is frequency count, another numeric variables can be
associated with across variable, which can be achieved by placing a comma(,)
between the Two variables in the COLUMN statement.
COMPUTED does not exist in the original dataset, it is created temporarily for the
reporting only. And define in the compute block. Compute block begins with
COMPUTE, Ends with ENDCOMP.
.SUM is a special convention in PROC REPORT
-IT sums up the values for a variables
-Need to be used in COMPUTE block
Tabulate Data With PROC TABULATE
Syntax:
Proc Tabulate Data=xxxx <options>;
Class XXXX;
Var XXXX;
Tables XXXX;
Run;
Categorical(always nominal) variables are often defined as class variable
The CLASS statement tells SAS which variables contain categorical data to be used
for dividing observations into groups
The TABLE statement tells SAS how to organize your table and what numbers to
compute.
Each TABLE statement defines only one table, but you may have multiple TABLE
statements.
Only numeric variables can be defined as analysis variable
A variable can be defined as either class or analysis variable, but not both
VAR statement tells SAS which variables contain continuous data
Default statistics:
-Frequency count for class variables
-Sum for analysis variables
-Use KEYLABEL to label statistics
Tabulate Data With PROC TABULATE
Missing Value
Missing value for class variable causes observations to be omitted in table generation
To treat missing value in class variable as valid category, using MISSING option for the
procedure
Missing value for analysis variable are reflected in frequency count, but not included in
the calculation for other statistics

Complex tables can be made with combination of:
Dimension
-Can have one, two, three dimension table
Concatenation -
Crossing -
Group
-With statistics, format and so on..
Tabulate Data With PROC TABULATE
Dimension
-Can have one, two, three dimension table
1D- it becomes, by default, the column dimension
2D- you get rows and columns but no page dimension
3D you get pages, rows and columns

Concatenation - To concatenate variables or keywords simply list them separated by a
space
Crossing - to cross variables or keywords separate then with an asterisk (*),
Group to group them enclose the variables or keywords in parentheses

Example
Concatenating: TABLE Class Gender;
Crossing: TABLE CLASS, gender*SALARY*MEAN*F=DOLLAR12.2;
Crossing, grouping, and concatenating: TABLE PCTN *(Locomotion Type);

Using PROC PLOT
Use Proc Plot to create simple plot:
Syntax

Proc Plot Data=XXXX <options>;
plot yvar*xvar/ <options>;
Run;
Quit;

PROC PLOT comes with base SAS software
By default, the procedure use character A Z to represent data point(to change the
Character .. (plot s1*year='*' ) put sign in quotation mark

Multiple plots can be generated in one PLOT statement
To overlay plots use OVERLAY option
Use QUIT to indicate the ending of the procedure

Using PROC GPLOT and PROC GCHART
PROC GPLOT and PROC GCHART comes from a SAS software called SAS/GREAPH
Compared to similar graph procedure offered by Base SAS, SAS/GREAPH creates graph
with rich Visual effect

Syntax
Proc Gplot Data=XXXX <options>;
plot yvar*xvar;
Run;
Quit;

Legend can be generated by using a third variable
Use SYMBOL statement to enhance the appearance of lines in the plot

PROC GCHART
Can create horizontal bar chart, vertical bar chart, or pie chart
Syntax for bar chart
Proc Gchart Data=XXXX <options>;
vbar XXXX/<options>;
hbar XXXX/<options>;
Run;
Quit;
Using PROC GPLOT and PROC GCHART
You can also generate 3 dimensional bar chart
Proc Gchart Data=XXXX <options>;
vbar3d XXXX/<options>;
hbar3d XXXX/<options>;
Run;
Quit;
Common option like SUMVAR to allow get the statistics of 2
nd
variable
Use PATTERN statement to enhance the appearance of lines in the plot

Syntax for pie chart, you can also generate 3D pie chart

Proc Gchart Data=XXXX <options>;
pie XXXX/<options>;
pie3d XXXX/<options>;
Run;
Quit;

S-ar putea să vă placă și