People.math.umass.edu



The print procedure

PROC PRINT data=data-set NOOBS LABEL;

By variable-list; Group output by the by-variables. Data must be presorted.

ID variable-list; The observation numbers are replaced by the ID variables.

SUM variable-list; Print sums for the variables in the list.

VAR variable-list; Specify variables to print and order

LABEL variable=’label’; Use label for the specified variable.

The NOOBS option requests the observation numbers to be suppressed. The LABEL option requests labels instead of variable names to be printed, if variable labels have been defined in a DATA step with a LABEL statement. Note that when a LABEL statement is used in a DATA step, the labels become part of the data set; but when used in a PROC, the labels stay in effect only for the duration of that step.

data shoes;

input style $ 1-15 ExcerciseType $ :10. Sales price;

datalines;

Max Flight running 1930 142.99

Zip fit leather walking 2250 83.99

zoom airborne running 4150 112.99

Light step walking 1130 73.99

Max step woven walking 2230 75.99

zip sneak c-train 1190 92.99

Air basketball 1000 150

;

proc sort data=shoes;

by ExerciseType;

proc print data=shoes label;

by ExerciseType;

sum sales;

var style sales price;

label Sales="sales in 2009";

run;

• The sort procedure

PROC SORT DATA=messy OUT=neat NODUPKEY;

BY state DESCENDING city;

The NODUPKEY option tells SAS to eliminate any duplicate observations that have the same values for the BY variables. The DESCENDING option before the city variable requests SAS to sort by descending order of the city. By default, SAS sorts by ascending order.

proc sort data=shoes out=shoes_sorted NODUPKEY;

by ExerciseType;

run;

proc print; run;

• The format procedure: mainly used to recode variable values through user-defined formats.

PROC FORMAT library=libref.catalogname ; 

    VALUE  numfmt  value1='formatted-value-1'   value2='formatted-value-2' 

        ........ valuen='formatted-value-n' ; 

    VALUE  $charfmt  'value1'='formatted-value-1'   'value2'='formatted-value-2'

        ........ 'valuen'='formatted-value-n' ; 

RUN;

PROC FORMAT Statement:  Without the LIBRARY=option, formats are stored in a catalog called FORMATS in the temporary WORK library and exist only for the duration of the SAS session. If the LIBRARY= option specifies only a libref, formats are permanently stored in that library in a catalog called FORMATS.

data temp;

infile cards dlm=',';

input id $ sex $ emp_stat yr_edu jobcat $ ;

cards;

A, m, 2, 18, 42

B, F, 0, 16, 00

C, f, 2, 16, 32

D, M, 1, 12, 52

E, f, 1, 18, 01

;

run;

proc format;

value $job '01'='Teacher'

'31'-'33'='Computing Consultant'

'41'-'49','51'-'59'='Medical Professional'

other='N/A' ;

value empst 0='NotEmployed'

1='Part-time Employed'

2='Full-time Employed' ;

value edu_cat 1-11='Less than High School'

12='High School'

12 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download