STANDARD Procedure

Example 1: Standardizing to a Given Mean and Standard Deviation

Features:
PROC STANDARD statement options:
MEAN=
OUT=
STD=

VAR statement

Other features:

PRINT procedure

Details

This example does the following:
  • standardizes two variables to a mean of 75 and a standard deviation of 5
  • specifies the output data set
  • combines standardized variables with original variables
  • prints the output data set

Program

options nodate pageno=1 linesize=80 pagesize=60;
data score;
   length Student $ 9;
   input Student $ StudentNumber Section $
         Test1 Test2 Final @@;
   format studentnumber z4.;
   datalines;
Capalleti 0545 1 94 91 87  Dubose    1252 2 51 65 91
Engles    1167 1 95 97 97  Grant     1230 2 63 75 80
Krupski   2527 2 80 69 71  Lundsford 4860 1 92 40 86
McBane    0674 1 75 78 72  Mullen    6445 2 89 82 93
Nguyen    0886 1 79 76 80  Patel     9164 2 71 77 83
Si        4915 1 75 71 73  Tanaka    8534 2 87 73 76
;
proc standard data=score mean=75 std=5 out=stndtest;
   var test1 test2;
run;
proc sql;
   create table combined as
   select old.student, old.studentnumber,
          old.section,
          old.test1, new.test1 as StdTest1,
          old.test2, new.test2 as StdTest2,
          old.final
   from score as old, stndtest as new
   where old.student=new.student;
proc print data=combined noobs round;
   title 'Standardized Test Scores for a College Course';
run;

Program Description

Set the SAS system options. The NODATE option specifies to omit the date and time when the SAS job began. The PAGENO= option specifies the page number for the next page of output that SAS produces. The LINESIZE= option specifies the line size. The PAGESIZE= option specifies the number of lines for a page of SAS output.
options nodate pageno=1 linesize=80 pagesize=60;
Create the SCORE data set. This data set contains test scores for students who took two tests and a final exam. The FORMAT statement assigns the Zw.d format to StudentNumber. This format pads right-justified output with 0s instead of blanks. The LENGTH statement specifies the number of bytes to use to store values of Student.
data score;
   length Student $ 9;
   input Student $ StudentNumber Section $
         Test1 Test2 Final @@;
   format studentnumber z4.;
   datalines;
Capalleti 0545 1 94 91 87  Dubose    1252 2 51 65 91
Engles    1167 1 95 97 97  Grant     1230 2 63 75 80
Krupski   2527 2 80 69 71  Lundsford 4860 1 92 40 86
McBane    0674 1 75 78 72  Mullen    6445 2 89 82 93
Nguyen    0886 1 79 76 80  Patel     9164 2 71 77 83
Si        4915 1 75 71 73  Tanaka    8534 2 87 73 76
;
Generate the standardized data and create the output data set STNDTEST. PROC STANDARD uses a mean of 75 and a standard deviation of 5 to standardize the values. OUT= identifies STNDTEST as the data set to contain the standardized values.
proc standard data=score mean=75 std=5 out=stndtest;
Specify the variables to standardize. The VAR statement specifies the variables to standardize and their order in the output.
   var test1 test2;
run;
Create a data set that combines the original values with the standardized values. PROC SQL joins SCORE and STNDTEST to create the COMBINED data set (table) that contains standardized and original test scores for each student. Using AS to rename the standardized variables NEW.TEST1 to StdTest1 and NEW.TEST2 to StdTest2 makes the variable names unique.
proc sql;
   create table combined as
   select old.student, old.studentnumber,
          old.section,
          old.test1, new.test1 as StdTest1,
          old.test2, new.test2 as StdTest2,
          old.final
   from score as old, stndtest as new
   where old.student=new.student;
Print the data set. PROC PRINT prints the COMBINED data set. ROUND rounds the standardized values to two decimal places. The TITLE statement specifies a title.
proc print data=combined noobs round;
   title 'Standardized Test Scores for a College Course';
run;
The following data set contains variables with both standardized and original values. StdTest1 and StdTest2 store the standardized test scores that PROC STANDARD computes.
                 Standardized Test Scores for a College Course                 1

               Student                         Std               Std
  Student      Number     Section    Test1    Test1    Test2    Test2    Final

  Capalleti     0545         1         94     80.54      91     80.86      87
  Dubose        1252         2         51     64.39      65     71.63      91
  Engles        1167         1         95     80.91      97     82.99      97
  Grant         1230         2         63     68.90      75     75.18      80
  Krupski       2527         2         80     75.28      69     73.05      71
  Lundsford     4860         1         92     79.79      40     62.75      86
  McBane        0674         1         75     73.40      78     76.24      72
  Mullen        6445         2         89     78.66      82     77.66      93
  Nguyen        0886         1         79     74.91      76     75.53      80
  Patel         9164         2         71     71.90      77     75.89      83
  Si            4915         1         75     73.40      71     73.76      73
  Tanaka        8534         2         87     77.91      73     74.47      76