Chapter Contents

Previous

Next
The STANDARD Procedure

Example 2: Standardizing BY Groups and Replacing Missing Values


Procedure features:
PROC STANDARD statement options:
PRINT
REPLACE
BY statement
Other features:
FORMAT procedure
PRINT procedure
SORT procedure

This example



Program
 Note about code
options nodate pageno=1 linesize=80 pagesize=60;
proc format;
   value popfmt 1='Stable'
                2='Rapid';
run;
 Note about code
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
;
 Note about code
proc sort data=lifexp;
   by populationrate;
run;
 Note about code
proc standard data=lifexp mean=0 std=1 replace
              print out=zscore;


 Note about code
   by populationrate;
 Note about code
   format populationrate popfmt.;
   title1 'Life Expectancies by Birth Rate';
run;
 Note about code
proc print data=zscore noobs;
   title 'Standardized Life Expectancies at Birth';
   title2 'by a Country''s Birth Rate';
run;


Output
PROC STANDARD prints the variable name, mean, standard deviation, input frequency, and label of each variable to standardize for each BY group.

Life expectancies for Bangladesh, Mozambique, and Russia are no longer missing. The missing values are replaced with the given mean (0).

[HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.