Procedure features: |
PROC STANDARD statement options:
|
BY statement |
|
Other features: |
FORMAT procedure |
PRINT procedure |
SORT procedure |
|
This example
-
calculates Z scores separately for each BY group using a mean
of 0 and standard deviation of 1
-
replaces missing values with the given mean
-
prints the mean and standard deviation for the variables to
standardize
-
prints the output data set.
|
options nodate pageno=1 linesize=80 pagesize=60; |
|
proc format;
value popfmt 1='Stable'
2='Rapid';
run; |
|
data lifexp;
input PopulationRate Country $char14. Life50 Life93 @@;
label life50='1950 life expectancy'
life93='1993 life expectancy';
datalines;
2 Bangladesh . 53 2 Brazil 51 67
2 China 41 70 2 Egypt 42 60
2 Ethiopia 33 46 1 France 67 77
1 Germany 68 75 2 India 39 59
2 Indonesia 38 59 1 Japan 64 79
2 Mozambique . 47 2 Philippines 48 64
1 Russia . 65 2 Turkey 44 66
1 United Kingdom 69 76 1 United States 69 75
; |
|
proc sort data=lifexp;
by populationrate;
run; |
|
proc standard data=lifexp mean=0 std=1 replace
print out=zscore; |
|
by populationrate; |
|
format populationrate popfmt.;
title1 'Life Expectancies by Birth Rate';
run; |
|
proc print data=zscore noobs;
title 'Standardized Life Expectancies at Birth';
title2 'by a Country''s Birth Rate';
run; |
|
Life Expectancies by Birth Rate 1
---------------------------- PopulationRate=Stable -----------------------------
Standard
Name Mean Deviation N Label
Life50 67.400000 1.854724 5 1950 life expectancy
Life93 74.500000 4.888763 6 1993 life expectancy
----------------------------- PopulationRate=Rapid -----------------------------
Standard
Name Mean Deviation N Label
Life50 42.000000 5.033223 8 1950 life expectancy
Life93 59.100000 8.225300 10 1993 life expectancy
Standardized Life Expectancies at Birth 2
by a Country's Birth Rate
Population
Rate Country Life50 Life93
Stable France -0.21567 0.51138
Stable Germany 0.32350 0.10228
Stable Japan -1.83316 0.92048
Stable Russia 0.00000 -1.94323
Stable United Kingdom 0.86266 0.30683
Stable United States 0.86266 0.10228
Rapid Bangladesh 0.00000 -0.74161
Rapid Brazil 1.78812 0.96045
Rapid China -0.19868 1.32518
Rapid Egypt 0.00000 0.10942
Rapid Ethiopia -1.78812 -1.59265
Rapid India -0.59604 -0.01216
Rapid Indonesia -0.79472 -0.01216
Rapid Mozambique 0.00000 -1.47107
Rapid Philippines 1.19208 0.59572
Rapid Turkey 0.39736 0.83888
| |
|
|
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.