options ls=132 ps=53 nocenter;

*****************************************************************;
* SF36V2-4_PUBLIC.SAS
* SAS CODE FOR SCORING 36-ITEM HEALTH SURVEY VERSION 2.0
* STANDARD FORM (NOT ACUTE!);
* WRITTEN BY K. SPRITZER, 9/29/2003
*
* MODIFIED: 2/14/2006 TO ADD AGE/GENDER ADJUSTMENT AND ADD PCS AND MCS
  SCORES.
  ALSO REQUIRED MODIFICATION OF AGE GROUPINGS: V1 HAD 18-24, 25-34,
  35-44, 45-54, 55-64, 65+ WHEREAS V2 BREAKS 65+ INTO 65-74 AND 75+.
  
* MODIFIED: 2/27/2007 TO USE SEPI FARIVAR WEIGHTS.  SEE COMMENTS
  FOR REFERENCE.
  ALSO SOME RESTRUCTURING OF CODE.  
  
* EVERY EFFORT IS MADE TO TEST CODE AS THOROUGHLY AS POSSIBLE BUT
  USER MUST ACCEPT RESPONSIBILITY FOR USE.
  PLEASE REPORT ANY CONCERNS OR PROBLEMS WITH THE CODE TO 
  K. SPRITZER AT KSPRITZER@MEDNET.UCLA.EDU - THANKS.             ;
*****************************************************************;

/* INPUT A FEW DUMMY TEST CASES */
/* INCLUDES SOME OUT OF RANGE DATA */

DATA TEMP1;
INPUT
I1 I2 I3A I3B I3C I3D I3E I3F I3G I3H I3I I3J 
I4A I4B I4C I4D I5A I5B I5C I6 I7 I8 
I9A I9B I9C I9D I9E I9F I9G I9H I9I I10
I11A I11B I11C I11D AGE MALE;
CARDS;
4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 42 1
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 33 1
3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 25 0
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 45 0
4 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 0
2 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 67 1
1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 1 1 1 2 1 1 1 1 1 1 1 1 2 2 2 1 1 2 1 1 1  . 1
1 1 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 5 5 1 1 5 5 1 5 5 5 1 5 1 77 1
1 1 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 6 6 1 1 6 6 1 6 5 5 1 5 1 56 0
5 5 1 1 1 . . . . . . . 1 1 1 1 1 1 1 5 6 5 6 1 1 6 6 1 1 6 1 1 . . . 5 48 1
;
RUN;

DATA TEMP1; SET TEMP1;
/** RENAME ITEMS TO CONFORM TO SURVEY **/
RENAME
I1   = I1
I2   = I2
I3A  = I3
I3B  = I4
I3C  = I5
I3D  = I6
I3E  = I7
I3F  = I8
I3G  = I9
I3H  = I10
I3I  = I11
I3J  = I12
I4A  = I13
I4B  = I14
I4C  = I15
I4D  = I16
I5A  = I17
I5B  = I18
I5C  = I19
I6   = I20
I7   = I21
I8   = I22
I9A  = I23
I9B  = I24
I9C  = I25
I9D  = I26
I9E  = I27
I9F  = I28
I9G  = I29
I9H  = I30
I9I  = I31
I10  = I32
I11A = I33
I11B = I34
I11C = I35
I11D = I36 ;
RUN;
*********************************************************;
DATA TEMP1; SET TEMP1;
*********************************************************;
** CODE OUT-OF-RANGE VALUES TO MISSING;
*********************************************************;
ARRAY PT3 I3-I12;
DO OVER PT3;
IF PT3 NOT IN (1,2,3) THEN PT3=.;
END;

ARRAY PT5 I1 I2 I13-I20 I22-I36;
DO OVER PT5;
IF PT5 NOT IN (1,2,3,4,5) THEN PT5=.;
END;

IF I21 NOT IN (1,2,3,4,5,6) THEN I21=.;
RUN;
*********************************************************;

*********************************************************;
DATA TEMP1; SET TEMP1;
* KEEP AS IS: I3-I19, I24, I25, I28, I29, I31, I32, I33, I35;
*********************************************************;
* RAND versions of items;
RAND21=I21;
RAND22=I22;
RAND1=I1;
***************************************************************************;
** WHEN NECESSARY, REVERSE CODE ITEMS SO A HIGHER SCORE MEANS BETTER HEALTH;
***************************************************************************;
IF I21=1 THEN RI21=6.0; ELSE
IF I21=2 THEN RI21=5.4; ELSE
IF I21=3 THEN RI21=4.2; ELSE
IF I21=4 THEN RI21=3.1; ELSE
IF I21=5 THEN RI21=2.2; ELSE
IF I21=6 THEN RI21=1.0; 

IF I21>. THEN DO;
IF I22=1 & I21 =1 THEN RI22=6; ELSE
IF I22=1 & I21>=2 THEN RI22=5; ELSE
IF I22=2 & I21>=1 THEN RI22=4; ELSE
IF I22=3 & I21>=1 THEN RI22=3; ELSE
IF I22=4 & I21>=1 THEN RI22=2; ELSE
IF I22=5 & I21>=1 THEN RI22=1;
END;
ELSE IF I21=. THEN DO;
IF I22=1 THEN RI22=6.0 ; ELSE
IF I22=2 THEN RI22=4.75; ELSE
IF I22=3 THEN RI22=3.5 ; ELSE
IF I22=4 THEN RI22=2.25; ELSE
IF I22=5 THEN RI22=1.0 ; 
END;

IF I1=1 THEN RI1=5.0; ELSE
IF I1=2 THEN RI1=4.4; ELSE
IF I1=3 THEN RI1=3.4; ELSE
IF I1=4 THEN RI1=2.0; ELSE
IF I1=5 THEN RI1=1.0; 

ARRAY CAT5   I2  I20  I23  I26  I27  I30  I34  I36 ;
ARRAY RCAT5  RI2 RI20 RI23 RI26 RI27 RI30 RI34 RI36;
DO OVER CAT5;
IF CAT5=1 THEN RCAT5=5; ELSE
IF CAT5=2 THEN RCAT5=4; ELSE
IF CAT5=3 THEN RCAT5=3; ELSE
IF CAT5=4 THEN RCAT5=2; ELSE
IF CAT5=5 THEN RCAT5=1;
END;

IF RAND21=1 THEN RRAND21=6; ELSE 
IF RAND21=2 THEN RRAND21=5; ELSE 
IF RAND21=3 THEN RRAND21=4; ELSE 
IF RAND21=4 THEN RRAND21=3; ELSE 
IF RAND21=5 THEN RRAND21=2; ELSE 
IF RAND21=6 THEN RRAND21=1;

IF RAND22=1 THEN RRAND22=5; ELSE 
IF RAND22=2 THEN RRAND22=4; ELSE 
IF RAND22=3 THEN RRAND22=3; ELSE 
IF RAND22=4 THEN RRAND22=2; ELSE 
IF RAND22=5 THEN RRAND22=1;  

IF RAND1=1 THEN RRAND1=5; ELSE 
IF RAND1=2 THEN RRAND1=4; ELSE 
IF RAND1=3 THEN RRAND1=3; ELSE 
IF RAND1=4 THEN RRAND1=2; ELSE 
IF RAND1=5 THEN RRAND1=1;  

*****************************************************************;
** RE-CODE ITEMS TO 0-100;
*****************************************************************;
ARRAY FIVEPT RI1 RI2 I13-I16 
      I17-I19 
      RI20  
      RI23 I24 I25 RI26 RI27 I28 I29 RI30 I31 
      I32 
      I33 RI34 I35 RI36
      RRAND1 RRAND22;

ARRAY SIXPT RI21 RI22
            RRAND21;

ARRAY THREEPT I3-I12;
          
DO OVER FIVEPT;
FIVEPT=(FIVEPT-1)*25;
END;

DO OVER SIXPT;
SIXPT=(SIXPT-1)*20;
END;

DO OVER THREEPT;
THREEPT=(THREEPT-1)*50;
END;          

** CREATE SCALES;

PHYFUN10=MEAN(I3,I4,I5,I6,I7,I8,I9,I10,I11,I12);
ROLEP4=MEAN(I13,I14,I15,I16);
SFPAIN2=MEAN(RI21,RI22);
SFGENH5=MEAN(RI1,I33,RI34,I35,RI36);
ENFAT4=MEAN(RI23,RI27,I29,I31);
SOCFUN2=MEAN(RI20,I32);
ROLEE3=MEAN(I17,I18,I19);
EMOT5=MEAN(I24,I25,RI26,I28,RI30);

PAIN2=MEAN(RRAND21,RRAND22);
GENH5=MEAN(RRAND1,I33,RI34,I35,RI36);

label phyfun10="Physical functioning scale";
label rolep4="Physical health problems scale";
label sfpain2="SF-36 pain scale";
label sfgenh5="SF-36 general health perceptions scale";
label enfat4="Energy/fatigue scale";
label socfun2="Social functioning scale";
label rolee3="Emotional health problems scale";
label emot5="Emotional well-being scale";

label pain2="Pain scale (RAND)";
label genh5="General health perceptions scale (RAND)";

** APPLY OPTION THAT REQUIRES AT LEAST HALF OF ITEMS IN A SCALE TO BE PRESENT 
   IN ORDER THAT THE SCALE BE NON-MISSING;
** NEED AT LEAST HALF (OR HALF + 1 FOR SCALES WITH ODD # OF ITEMS) OF ITEMS PRESENT, 
   ELSE SET SCALE TO MISSING;

/* UNCOMMENT THIS SECTION IF YOU WANT TO USE THE OPTION */
/*
IF N(OF I3,I4,I5,I6,I7,I8,I9,I10,I11,I12) <=4 THEN PHYFUN10=.;
IF N(OF I13,I14,I15,I16)                  <=1 THEN ROLEP4  =.;
* IF N(OF RI21,RI22)                      <=0 THEN SFPAIN2 =.;
IF N(OF RI1,I33,RI34,I35,RI36)            <=2 THEN SFGENH5 =.;
IF N(OF RI23,RI27,I29,I31)                <=1 THEN ENFAT4  =.;
* IF N(OF RI20,I32)                       <=0 THEN SOCFUN2 =.;
IF N(OF I17,I18,I19)                      <=1 THEN ROLEE3  =.;
IF N(OF I24,I25,RI26,I28,RI30)            <=2 THEN EMOT5   =.;

* IF N(OF RRAND21,RRAND22)                <=0 THEN PAIN2 =.;
IF N(OF RRAND1,I33,RI34,I35,RI36)         <=2 THEN GENH5 =.;
*/

*****************************************************************;
*** NEMC PHYSICAL AND MENTAL HEALTH COMPOSITE - SF36 ************;
*****************************************************************;

*** 1) Transform SF-36 scores (NEMC Scoring) to z-scores; ******* ;
***    1998 US general population means and SDs are used here ** ;
***    (not age/gender based) *********************************** ;

   PF_Z = (PHYFUN10 - 83.29094) / 23.75883 ;
   RP_Z = (ROLEP4   - 82.50964) / 25.52028 ;
   BP_Z = (SFPAIN2  - 71.32527) / 23.66224 ;
   GH_Z = (SFGENH5  - 70.84570) / 20.97821 ;
   EM_Z = (EMOT5    - 74.98685) / 17.75604 ;
   RE_Z = (ROLEE3   - 87.39733) / 21.43778 ;
   SF_Z = (SOCFUN2  - 84.30250) / 22.91921 ;
   EN_Z = (ENFAT4   - 58.31411) / 20.01923 ;

   label pf_Z="NEMC physical functioning Z-score";
   label rp_Z="NEMC role limitation physical Z-score";
   label bp_Z="NEMC pain Z-score";
   label gh_Z="NEMC general health Z-score";
   label em_Z="NEMC emotional well-being Z-score";
   label re_Z="NEMC role limitation emotional Z-score";
   label sf_Z="NEMC social functioning Z-score";
   label en_Z="NEMC energy/fatigue Z-score";

*** 2) Create physical and mental health composite scores: **********;
***    Multiply z-scores by varimax-rotated factor scoring **********;
***    coefficients and sum the products ****************************;

*** NOTE: Aggregates are missing if any subscale score is missing - Qualitymetric has
    a missing data estimator (MDE) product that will allow scoring of aggregates
    when 1 or more subscales are missing.
    See: http://www.qualitymetric.com/products/SFScoring/ScoringMDE.aspx for 
    more information. 
    ;

   AGG_PHYS = (PF_Z * 0.42402) + (RP_Z * 0.35119) + (BP_Z * 0.31754) +
              (GH_Z * 0.24954) + (EM_Z * -.22069) + (RE_Z * -.19206) +
              (SF_Z * -.00753) + (EN_Z * 0.02877);
              
   AGG_MENT = (PF_Z * -.22999) + (RP_Z * -.12329) + (BP_Z * -.09731) +
              (GH_Z * -.01571) + (EM_Z * 0.48581) + (RE_Z * 0.43407) +
              (SF_Z * 0.26876) + (EN_Z * 0.23534);

   label agg_phys="NEMC physical health - SF36 (raw)";
   label agg_ment="NEMC mental health - SF36 (raw)";

*** 3) Transform composite and scale scores to T-scores: ****** ;

   AGG_PHYS_T = 50 + (AGG_PHYS * 10);
   AGG_MENT_T = 50 + (AGG_MENT * 10);

   label agg_phys_t="NEMC physical health T-score - SF36";
   label agg_ment_t="NEMC mental health T-score - SF36";
   PF_T = 50 + (PF_Z * 10) ;
   RP_T = 50 + (RP_Z * 10) ;
   BP_T = 50 + (BP_Z * 10) ;
   GH_T = 50 + (GH_Z * 10) ;
   EM_T = 50 + (EM_Z * 10) ;
   RE_T = 50 + (RE_Z * 10) ;
   SF_T = 50 + (SF_Z * 10) ;
   EN_T = 50 + (EN_Z * 10) ;

   label pf_t="NEMC physical functioning T-score";
   label rp_t="NEMC role limitation physical T-score";
   label bp_t="NEMC pain T-score";
   label gh_t="NEMC general health T-score";
   label em_t="NEMC emotional well-being T-score";
   label re_t="NEMC role limitation emotional T-score";
   label sf_t="NEMC social functioning T-score";
   label en_t="NEMC energy/fatigue T-score";

*****************************************************************;
*** PHYSICAL and MENTAL HEALTH FACTORS **************************;
*****************************************************************;

*** 1) Derive z-scores using age/gender adjusted US general *****;
***    population means and SDs, then multiply each z-score by *;
***    oblique factor scoring coefficient and sum the products **;

*** Feb 2007: oblique factor scoring coeffs come from:

**  Farivar, S. S., Cunningham, W. E., & Hays, R. D. (in press).
    Correlated physical and mental health summary scores for the
    SF-36 and SF-12 Health Survey, V.1., Journal of Health and
    Quality of Life Outcomes.
;

  FFM1=   0.19868 * (PHYFUN10 - 79.9348918)/ 22.709038+
          0.31059 * (ROLEP4   - 76.2860947)/ 34.945958+
          0.22602 * (SFPAIN2  - 72.6616442)/ 23.807217+
          0.19548 * (SFGENH5  - 69.3384676)/ 20.141323+
         -0.03009 * (EMOT5    - 74.6684030)/ 18.209059+
          0.02738 * (ROLEE3   - 79.9677043)/ 34.229373+
          0.10511 * (SOCFUN2  - 82.1785891)/ 23.568127+
          0.13093 * (ENFAT4   - 59.5636224)/ 21.334831;

  FFM2=  -0.01520 * (PHYFUN10 - 79.9348918)/ 22.709038+ 
          0.03496 * (ROLEP4   - 76.2860947)/ 34.945958+
          0.04327 * (SFPAIN2  - 72.6616442)/ 23.807217+
          0.10379 * (SFGENH5  - 69.3384676)/ 20.141323+
          0.35362 * (EMOT5    - 74.6684030)/ 18.209059+
          0.19588 * (ROLEE3   - 79.9677043)/ 34.229373+
          0.13950 * (SOCFUN2  - 82.1785891)/ 23.568127+
          0.28769 * (ENFAT4   - 59.5636224)/ 21.334831 ;

label ffm1 = "Physical health factor score";
label ffm2 = "Mental health factor score";

*** 2) Transform composite scores to t-scores *******************;

  FSFM1 = (FFM1 * 10) +50;
  FSFM2 = (FFM2 * 10) +50;

  label fsfm1="Physical health factor T-score";
  label fsfm2="Mental health factor T-score";

run;

*****************************************************************;
TITLE1 "SF36 V2 (all cases)";
PROC MEANS data=TEMP1; 
VAR phyfun10 rolep4 sfpain2 pain2 sfgenh5 genh5 emot5 rolee3 socfun2 enfat4 agg_phys agg_ment
pf_t rp_t bp_t gh_t em_t re_t sf_t en_t AGG_PHYS_T AGG_MENT_T
ffm1 ffm2 fsfm1 fsfm2;
run;
*****************************************************************;
TITLE1 "SF36 V2 (cases with non-missing age and gender)";
PROC MEANS data=TEMP1; where age > . & male > .; 
VAR phyfun10 rolep4 sfpain2 pain2 sfgenh5 genh5 emot5 rolee3 socfun2 enfat4 agg_phys agg_ment
pf_t rp_t bp_t gh_t em_t re_t sf_t en_t AGG_PHYS_T AGG_MENT_T
ffm1 ffm2 fsfm1 fsfm2;
run;
*****************************************************************;

/*----------------------------------------------------------------------------------------------*/
* optional age/gender adjust ;
/* CODE TO COMPARE TO U.S. GENERAL POPULATION NORMS */
/* REQUIRES (continuous) AGE AND (an indicator variable for) MALE GENDER (1=male, 0=female) */

DATA TEMP1; SET TEMP1;

IF 18<=AGE AND MALE>=0 THEN DO;
SFAGE1=0;SFAGE2=0;SFAGE3=0;SFAGE4=0;SFAGE5=0;
SFAGE6=0;SFAGE7=0;SFAGE8=0;SFAGE9=0;
SFAGE10=0;SFAGE11=0;SFAGE12=0;SFAGE13=0;SFAGE14=0;
END;

IF 18<=AGE<=24 AND MALE=1 THEN SFAGE1=1;
IF 24<AGE<=34  AND MALE=1 THEN SFAGE2=1;
IF 34<AGE<=44  AND MALE=1 THEN SFAGE3=1;
IF 44<AGE<=54  AND MALE=1 THEN SFAGE4=1;
IF 54<AGE<=64  AND MALE=1 THEN SFAGE5=1;
IF 64<AGE<=74  AND MALE=1 THEN SFAGE6=1;
IF 74<AGE      AND MALE=1 THEN SFAGE7=1;

IF 18<=AGE<=24 AND MALE=0 THEN SFAGE8=1;
IF 24<AGE<=34  AND MALE=0 THEN SFAGE9=1;
IF 34<AGE<=44  AND MALE=0 THEN SFAGE10=1;
IF 44<AGE<=54  AND MALE=0 THEN SFAGE11=1;
IF 54<AGE<=64  AND MALE=0 THEN SFAGE12=1;
IF 64<AGE<=74  AND MALE=0 THEN SFAGE13=1;
IF 74<AGE      AND MALE=0 THEN SFAGE14=1;
*********************************************************;
RUN;

***********************************************************;
**Read in dataset containing US general population means***;
**and standard deviations for each SF-36 scale, by each****;
**age/gender group;
***********************************************************;
DATA GENPOP;
input

#1
PF1       1-5 PF2    7-11 PF3   13-17 PF4   19-23 PF5   25-29 PF6  31-35 PF7  37-41
PF8     43-47 PF9   49-53 PF10  55-59 PF11  61-65 PF12  67-71 PF13 73-77 PF14 79-83
#2
PF1S      1-5 PF2S   7-11 PF3S  13-17 PF4S  19-23 PF5S  25-29 PF6S  31-35 PF7S  37-41
PF8S    43-47 PF9S  49-53 PF10S 55-59 PF11S 61-65 PF12S 67-71 PF13S 73-77 PF14S 79-83
#3
RP1       1-5 RP2    7-11 RP3   13-17 RP4   19-23 RP5   25-29 RP6  31-35 RP7  37-41
RP8     43-47 RP9   49-53 RP10  55-59 RP11  61-65 RP12  67-71 RP13 73-77 RP14 79-83
#4
RP1S      1-5 RP2S   7-11 RP3S  13-17 RP4S  19-23 RP5S  25-29 RP6S  31-35 RP7S  37-41
RP8S    43-47 RP9S  49-53 RP10S 55-59 RP11S 61-65 RP12S 67-71 RP13S 73-77 RP14S 79-83
#5
BP1       1-5 BP2    7-11 BP3   13-17 BP4   19-23 BP5   25-29 BP6  31-35 BP7  37-41
BP8     43-47 BP9   49-53 BP10  55-59 BP11  61-65 BP12  67-71 BP13 73-77 BP14 79-83
#6
BP1S      1-5 BP2S   7-11 BP3S  13-17 BP4S  19-23 BP5S  25-29 BP6S  31-35 BP7S  37-41
BP8S    43-47 BP9S  49-53 BP10S 55-59 BP11S 61-65 BP12S 67-71 BP13S 73-77 BP14S 79-83
#7
GEN1       1-5 GEN2    7-11 GEN3   13-17 GEN4   19-23 GEN5   25-29 GEN6  31-35 GEN7  37-41
GEN8     43-47 GEN9   49-53 GEN10  55-59 GEN11  61-65 GEN12  67-71 GEN13 73-77 GEN14 79-83
#8
GEN1S      1-5 GEN2S   7-11 GEN3S  13-17 GEN4S  19-23 GEN5S  25-29 GEN6S  31-35 GEN7S  37-41
GEN8S    43-47 GEN9S  49-53 GEN10S 55-59 GEN11S 61-65 GEN12S 67-71 GEN13S 73-77 GEN14S 79-83
#9
ENFT1       1-5 ENFT2    7-11 ENFT3   13-17 ENFT4   19-23 ENFT5   25-29 ENFT6  31-35 ENFT7  37-41
ENFT8     43-47 ENFT9   49-53 ENFT10  55-59 ENFT11  61-65 ENFT12  67-71 ENFT13 73-77 ENFT14 79-83
#10
ENFT1S      1-5 ENFT2S   7-11 ENFT3S  13-17 ENFT4S  19-23 ENFT5S  25-29 ENFT6S  31-35 ENFT7S  37-41
ENFT8S    43-47 ENFT9S  49-53 ENFT10S 55-59 ENFT11S 61-65 ENFT12S 67-71 ENFT13S 73-77 ENFT14S 79-83
#11
SF1       1-5 SF2    7-11 SF3   13-17 SF4   19-23 SF5   25-29 SF6  31-35 SF7  37-41
SF8     43-47 SF9   49-53 SF10  55-59 SF11  61-65 SF12  67-71 SF13 73-77 SF14 79-83
#12
SF1S      1-5 SF2S   7-11 SF3S  13-17 SF4S  19-23 SF5S  25-29 SF6S  31-35 SF7S  37-41
SF8S    43-47 SF9S  49-53 SF10S 55-59 SF11S 61-65 SF12S 67-71 SF13S 73-77 SF14S 79-83
#13
RE1       1-5 RE2    7-11 RE3   13-17 RE4   19-23 RE5   25-29 RE6  31-35 RE7  37-41
RE8     43-47 RE9   49-53 RE10  55-59 RE11  61-65 RE12  67-71 RE13 73-77 RE14 79-83
#14
RE1S      1-5 RE2S   7-11 RE3S  13-17 RE4S  19-23 RE5S  25-29 RE6S  31-35 RE7S  37-41
RE8S    43-47 RE9S  49-53 RE10S 55-59 RE11S 61-65 RE12S 67-71 RE13S 73-77 RE14S 79-83
#15
MH1       1-5 MH2    7-11 MH3   13-17 MH4   19-23 MH5   25-29 MH6  31-35 MH7  37-41
MH8     43-47 MH9   49-53 MH10  55-59 MH11  61-65 MH12  67-71 MH13 73-77 MH14 79-83
#16
MH1S      1-5 MH2S   7-11 MH3S  13-17 MH4S  19-23 MH5S  25-29 MH6S  31-35 MH7S  37-41
MH8S    43-47 MH9S  49-53 MH10S 55-59 MH11S 61-65 MH12S 67-71 MH13S 73-77 MH14S 79-83
#17
PCS1       1-5 PCS2    7-11 PCS3   13-17 PCS4   19-23 PCS5   25-29 PCS6  31-35 PCS7  37-41
PCS8     43-47 PCS9   49-53 PCS10  55-59 PCS11  61-65 PCS12  67-71 PCS13 73-77 PCS14 79-83
#18
PCS1S      1-5 PCS2S   7-11 PCS3S  13-17 PCS4S  19-23 PCS5S  25-29 PCS6S  31-35 PCS7S  37-41
PCS8S    43-47 PCS9S  49-53 PCS10S 55-59 PCS11S 61-65 PCS12S 67-71 PCS13S 73-77 PCS14S 79-83
#19
MCS1       1-5 MCS2    7-11 MCS3   13-17 MCS4   19-23 MCS5   25-29 MCS6  31-35 MCS7  37-41
MCS8     43-47 MCS9   49-53 MCS10  55-59 MCS11  61-65 MCS12  67-71 MCS13 73-77 MCS14 79-83
#20
MCS1S      1-5 MCS2S   7-11 MCS3S  13-17 MCS4S  19-23 MCS5S  25-29 MCS6S  31-35 MCS7S  37-41
MCS8S    43-47 MCS9S  49-53 MCS10S 55-59 MCS11S 61-65 MCS12S 67-71 MCS13S 73-77 MCS14S 79-83;
datalines;
54.26 54.56 53.48 51.38 48.99 45.48 39.62 53.04 52.96 51.4  48.63 46.26 43.63 37.22
 7.22  6.16  6.45  8.6   9.84 10.93 12.53  6.56  7.16  8.59 10.06 11.07 11.35 12.21
54.5  53.64 52.86 51.06 48.93 46.04 39.67 51.66 51.73 51.35 49.56 47.78 45.09 40.44
 6.3   6.96  7.85  9.45 10.8  10.59 11.85  7.98  8.76  8.75 10.18 10.98 10.84 11.41
51.71 53.18 51.49 50.39 49.15 48.41 46.28 51.89 51.44 49.95 48.07 47.73 47.33 44.87
 8.42  8.7   8.92  9.69 10.6  10.03 10.68  8.43  9.64  9.64 10.29 11.09 10.38 11.07
52.02 52.5  51.75 50.27 49.19 48.16 44.28 48.14 50.86 50.15 49.23 48.98 48.6  46.32
 8.22  8.46  9.21  9.99 10.47 10.28 11.19  9.55  9.61  9.8  10.66 10.93 10.27 10.48
49.86 51.58 51.41 51.63 52.27 51.94 47.85 45.65 48.08 48.36 49.37 50.16 51.28 47.89
 9.65  8.51  9.5  10.14 10.42  9.92 10.67  8.82 10.11  9.92  9.98 10.9  10.23 10.49
50.84 52.46 51.41 50.43 50.6  50.28 45.56 48.26 49.43 49.3  49.69 49.31 49.92 46.15
 7     7.43  8.78 10.25 10.17  9.98 12.67 10.72  9.94 10.14 10.12 11.07 10.06 12.36
52.69 52.79 51.9  51.06 50.48 48.8  43.59 48.26 49.71 49.91 50.22 49.16 48.48 43.61
 5.93  7     8.14  9.42 10.18 11.18 14.24 10.92  9.64  9.62  9.9  11.06 10.53 12.65
49.76 51.28 50.36 50.79 52.41 53.98 50.84 45.34 47.78 47.74 49.6  50.19 51.66 50.41
 8.33  8.35  9.67 10.12  9.46  8.61 10.12 10.74 10.6  10.45  9.96 10.75  9.24 10.56
53.96 54.05 52.98 50.81 48.16 45.13 40.38 53.26 53.03 51.56 48.49 46.79 44.34 39.78
 7     6.63  7.6   9.37 10.23 10.16 11     7.18  7.91  8.62 10.47 11.18 11.06 11.4
49.51 51.02 50.39 50.85 52.53 53.66 50.04 44.43 47.14 47.8  50.24 50.95 52.78 50.57
 7.14  7.64  9.56 10.05  9.67  9.03 11.09 11.41 10.74 10.35  9.84 10.7   9.48 10.96
;
run;

****************************************************************;
**T-statistics for the difference between SF-36 sample scores***;
**compared to the US general population, for each US age/gender*;
**group***;
****************************************************************;

DATA TEMP1;
 IF _N_=1 THEN SET GENPOP;
 SET TEMP1;

PFISFM=(SFAGE1*PF1)  + (SFAGE2*PF2) +
       (SFAGE3*PF3)  + (SFAGE4*PF4) +
       (SFAGE5*PF5)  + (SFAGE6*PF6) +
       (SFAGE7*PF7)  + (SFAGE8*PF8) +
       (SFAGE9*PF9)  +(SFAGE10*PF10)+
       (SFAGE11*PF11)+(SFAGE12*PF12)+
       (SFAGE13*PF13)+(SFAGE14*PF14);

IF SFAGE1=1 THEN ZPHY10=(PF_T-PFISFM)/PF1S;
  ELSE IF SFAGE2=1 THEN ZPHY10=(PF_T-PFISFM)/PF2S;
  ELSE IF SFAGE3=1 THEN ZPHY10=(PF_T-PFISFM)/PF3S;
  ELSE IF SFAGE4=1 THEN ZPHY10=(PF_T-PFISFM)/PF4S;
  ELSE IF SFAGE5=1 THEN ZPHY10=(PF_T-PFISFM)/PF5S;
  ELSE IF SFAGE6=1 THEN ZPHY10=(PF_T-PFISFM)/PF6S;
  ELSE IF SFAGE7=1 THEN ZPHY10=(PF_T-PFISFM)/PF7S;
  ELSE IF SFAGE8=1 THEN ZPHY10=(PF_T-PFISFM)/PF8S;
  ELSE IF SFAGE9=1 THEN ZPHY10=(PF_T-PFISFM)/PF9S;
  ELSE IF SFAGE10=1 THEN ZPHY10=(PF_T-PFISFM)/PF10S;
  ELSE IF SFAGE11=1 THEN ZPHY10=(PF_T-PFISFM)/PF11S;
  ELSE IF SFAGE12=1 THEN ZPHY10=(PF_T-PFISFM)/PF12S;
  ELSE IF SFAGE13=1 THEN ZPHY10=(PF_T-PFISFM)/PF13S;
  ELSE IF SFAGE14=1 THEN ZPHY10=(PF_T-PFISFM)/PF14S;

RPSFM=(SFAGE1*RP1)+(SFAGE2*RP2)+(SFAGE3*RP3)+
       (SFAGE4*RP4)+ (SFAGE5*RP5)+ (SFAGE6*RP6)+
       (SFAGE7*RP7)+ (SFAGE8*RP8)+ (SFAGE9*RP9)+
       (SFAGE10*RP10)+ (SFAGE11*RP11)+ (SFAGE12*RP12) +
       (SFAGE13*RP13) + (SFAGE14*RP14);

IF SFAGE1=1 THEN ZRP=(RP_T-RPSFM)/RP1S;
  ELSE IF SFAGE2=1 THEN ZRP=(RP_T-RPSFM)/RP2S;
  ELSE IF SFAGE3=1 THEN ZRP=(RP_T-RPSFM)/RP3S;
  ELSE IF SFAGE4=1 THEN ZRP=(RP_T-RPSFM)/RP4S;
  ELSE IF SFAGE5=1 THEN ZRP=(RP_T-RPSFM)/RP5S;
  ELSE IF SFAGE6=1 THEN ZRP=(RP_T-RPSFM)/RP6S;
  ELSE IF SFAGE7=1 THEN ZRP=(RP_T-RPSFM)/RP7S;
  ELSE IF SFAGE8=1 THEN ZRP=(RP_T-RPSFM)/RP8S;
  ELSE IF SFAGE9=1 THEN ZRP=(RP_T-RPSFM)/RP9S;
  ELSE IF SFAGE10=1 THEN ZRP=(RP_T-RPSFM)/RP10S;
  ELSE IF SFAGE11=1 THEN ZRP=(RP_T-RPSFM)/RP11S;
  ELSE IF SFAGE12=1 THEN ZRP=(RP_T-RPSFM)/RP12S;
  ELSE IF SFAGE13=1 THEN ZRP=(RP_T-RPSFM)/RP13S;
  ELSE IF SFAGE14=1 THEN ZRP=(RP_T-RPSFM)/RP14S;

BPSFM=(SFAGE1*BP1)+(SFAGE2*BP2)+(SFAGE3*BP3)+
       (SFAGE4*BP4)+ (SFAGE5*BP5)+ (SFAGE6*BP6)+
       (SFAGE7*BP7)+ (SFAGE8*BP8)+ (SFAGE9*BP9)+
       (SFAGE10*BP10)+ (SFAGE11*BP11)+ (SFAGE12*BP12) +
       (SFAGE13*BP13) + (SFAGE14*BP14);

IF SFAGE1=1 THEN ZBP=(BP_T-BPSFM)/BP1S;
  ELSE IF SFAGE2=1 THEN ZBP=(BP_T-BPSFM)/BP2S;
  ELSE IF SFAGE3=1 THEN ZBP=(BP_T-BPSFM)/BP3S;
  ELSE IF SFAGE4=1 THEN ZBP=(BP_T-BPSFM)/BP4S;
  ELSE IF SFAGE5=1 THEN ZBP=(BP_T-BPSFM)/BP5S;
  ELSE IF SFAGE6=1 THEN ZBP=(BP_T-BPSFM)/BP6S;
  ELSE IF SFAGE7=1 THEN ZBP=(BP_T-BPSFM)/BP7S;
  ELSE IF SFAGE8=1 THEN ZBP=(BP_T-BPSFM)/BP8S;
  ELSE IF SFAGE9=1 THEN ZBP=(BP_T-BPSFM)/BP9S;
  ELSE IF SFAGE10=1 THEN ZBP=(BP_T-BPSFM)/BP10S;
  ELSE IF SFAGE11=1 THEN ZBP=(BP_T-BPSFM)/BP11S;
  ELSE IF SFAGE12=1 THEN ZBP=(BP_T-BPSFM)/BP12S;
  ELSE IF SFAGE13=1 THEN ZBP=(BP_T-BPSFM)/BP13S;
  ELSE IF SFAGE14=1 THEN ZBP=(BP_T-BPSFM)/BP14S;

GENSFM=(SFAGE1*GEN1)+(SFAGE2*GEN2)+(SFAGE3*GEN3)+
       (SFAGE4*GEN4)+ (SFAGE5*GEN5)+ (SFAGE6*GEN6)+
       (SFAGE7*GEN7)+ (SFAGE8*GEN8)+ (SFAGE9*GEN9)+
       (SFAGE10*GEN10)+ (SFAGE11*GEN11)+ (SFAGE12*GEN12) +
       (SFAGE13*GEN13) + (SFAGE14*GEN14);

IF SFAGE1=1 THEN ZGENH=(GH_T-GENSFM)/GEN1S;
  ELSE IF SFAGE2=1 THEN ZGENH=(GH_T-GENSFM)/GEN2S;
  ELSE IF SFAGE3=1 THEN ZGENH=(GH_T-GENSFM)/GEN3S;
  ELSE IF SFAGE4=1 THEN ZGENH=(GH_T-GENSFM)/GEN4S;
  ELSE IF SFAGE5=1 THEN ZGENH=(GH_T-GENSFM)/GEN5S;
  ELSE IF SFAGE6=1 THEN ZGENH=(GH_T-GENSFM)/GEN6S;
  ELSE IF SFAGE7=1 THEN ZGENH=(GH_T-GENSFM)/GEN7S;
  ELSE IF SFAGE8=1 THEN ZGENH=(GH_T-GENSFM)/GEN8S;
  ELSE IF SFAGE9=1 THEN ZGENH=(GH_T-GENSFM)/GEN9S;
  ELSE IF SFAGE10=1 THEN ZGENH=(GH_T-GENSFM)/GEN10S;
  ELSE IF SFAGE11=1 THEN ZGENH=(GH_T-GENSFM)/GEN11S;
  ELSE IF SFAGE12=1 THEN ZGENH=(GH_T-GENSFM)/GEN12S;
  ELSE IF SFAGE13=1 THEN ZGENH=(GH_T-GENSFM)/GEN13S;
  ELSE IF SFAGE14=1 THEN ZGENH=(GH_T-GENSFM)/GEN14S;

ENFTSFM=(SFAGE1*ENFT1)+(SFAGE2*ENFT2)+(SFAGE3*ENFT3)+
       (SFAGE4*ENFT4)+ (SFAGE5*ENFT5)+ (SFAGE6*ENFT6)+
       (SFAGE7*ENFT7)+ (SFAGE8*ENFT8)+ (SFAGE9*ENFT9)+
       (SFAGE10*ENFT10)+ (SFAGE11*ENFT11)+ (SFAGE12*ENFT12) +
       (SFAGE13*ENFT13) + (SFAGE14*ENFT14);

IF SFAGE1=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT1S;
  ELSE IF SFAGE2=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT2S;
  ELSE IF SFAGE3=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT3S;
  ELSE IF SFAGE4=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT4S;
  ELSE IF SFAGE5=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT5S;
  ELSE IF SFAGE6=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT6S;
  ELSE IF SFAGE7=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT7S;
  ELSE IF SFAGE8=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT8S;
  ELSE IF SFAGE9=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT9S;
  ELSE IF SFAGE10=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT10S;
  ELSE IF SFAGE11=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT11S;
  ELSE IF SFAGE12=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT12S;
  ELSE IF SFAGE13=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT13S;
  ELSE IF SFAGE14=1 THEN ZENFT=(EN_T-ENFTSFM)/ENFT14S;

SFSFM=(SFAGE1*SF1)+(SFAGE2*SF2)+(SFAGE3*SF3)+
       (SFAGE4*SF4)+ (SFAGE5*SF5)+ (SFAGE6*SF6)+
       (SFAGE7*SF7)+ (SFAGE8*SF8)+ (SFAGE9*SF9)+
       (SFAGE10*SF10)+ (SFAGE11*SF11)+ (SFAGE12*SF12) +
       (SFAGE13*SF13) + (SFAGE14*SF14);

IF SFAGE1=1 THEN ZSF=(SOCFUN2-SFSFM)/SF1S;
  ELSE IF SFAGE2=1 THEN ZSF=(SF_T-SFSFM)/SF2S;
  ELSE IF SFAGE3=1 THEN ZSF=(SF_T-SFSFM)/SF3S;
  ELSE IF SFAGE4=1 THEN ZSF=(SF_T-SFSFM)/SF4S;
  ELSE IF SFAGE5=1 THEN ZSF=(SF_T-SFSFM)/SF5S;
  ELSE IF SFAGE6=1 THEN ZSF=(SF_T-SFSFM)/SF6S;
  ELSE IF SFAGE7=1 THEN ZSF=(SF_T-SFSFM)/SF7S;
  ELSE IF SFAGE8=1 THEN ZSF=(SF_T-SFSFM)/SF8S;
  ELSE IF SFAGE9=1 THEN ZSF=(SF_T-SFSFM)/SF9S;
  ELSE IF SFAGE10=1 THEN ZSF=(SF_T-SFSFM)/SF10S;
  ELSE IF SFAGE11=1 THEN ZSF=(SF_T-SFSFM)/SF11S;
  ELSE IF SFAGE12=1 THEN ZSF=(SF_T-SFSFM)/SF12S;
  ELSE IF SFAGE13=1 THEN ZSF=(SF_T-SFSFM)/SF13S;
  ELSE IF SFAGE14=1 THEN ZSF=(SF_T-SFSFM)/SF14S;

RESFM=(SFAGE1*RE1)+(SFAGE2*RE2)+(SFAGE3*RE3)+
       (SFAGE4*RE4)+ (SFAGE5*RE5)+ (SFAGE6*RE6)+
       (SFAGE7*RE7)+ (SFAGE8*RE8)+ (SFAGE9*RE9)+
       (SFAGE10*RE10)+ (SFAGE11*RE11)+ (SFAGE12*RE12) +
       (SFAGE13*RE13) + (SFAGE14*RE14);

IF SFAGE1=1 THEN ZRE=(RE_T-RESFM)/RE1S;
  ELSE IF SFAGE2=1 THEN ZRE=(RE_T-RESFM)/RE2S;
  ELSE IF SFAGE3=1 THEN ZRE=(RE_T-RESFM)/RE3S;
  ELSE IF SFAGE4=1 THEN ZRE=(RE_T-RESFM)/RE4S;
  ELSE IF SFAGE5=1 THEN ZRE=(RE_T-RESFM)/RE5S;
  ELSE IF SFAGE6=1 THEN ZRE=(RE_T-RESFM)/RE6S;
  ELSE IF SFAGE7=1 THEN ZRE=(RE_T-RESFM)/RE7S;
  ELSE IF SFAGE8=1 THEN ZRE=(RE_T-RESFM)/RE8S;
  ELSE IF SFAGE9=1 THEN ZRE=(RE_T-RESFM)/RE9S;
  ELSE IF SFAGE10=1 THEN ZRE=(RE_T-RESFM)/RE10S;
  ELSE IF SFAGE11=1 THEN ZRE=(RE_T-RESFM)/RE11S;
  ELSE IF SFAGE12=1 THEN ZRE=(RE_T-RESFM)/RE12S;
  ELSE IF SFAGE13=1 THEN ZRE=(RE_T-RESFM)/RE13S;
  ELSE IF SFAGE14=1 THEN ZRE=(RE_T-RESFM)/RE14S;

MHSFM=(SFAGE1*MH1)+(SFAGE2*MH2)+(SFAGE3*MH3)+
       (SFAGE4*MH4)+ (SFAGE5*MH5)+ (SFAGE6*MH6)+
       (SFAGE7*MH7)+ (SFAGE8*MH8)+ (SFAGE9*MH9)+
       (SFAGE10*MH10)+ (SFAGE11*MH11)+ (SFAGE12*MH12) +
       (SFAGE13*MH13) + (SFAGE14*MH14);

IF SFAGE1=1 THEN ZMHI=(EM_T-MHSFM)/MH1S;
  ELSE IF SFAGE2=1 THEN ZMHI=(EM_T-MHSFM)/MH2S;
  ELSE IF SFAGE3=1 THEN ZMHI=(EM_T-MHSFM)/MH3S;
  ELSE IF SFAGE4=1 THEN ZMHI=(EM_T-MHSFM)/MH4S;
  ELSE IF SFAGE5=1 THEN ZMHI=(EM_T-MHSFM)/MH5S;
  ELSE IF SFAGE6=1 THEN ZMHI=(EM_T-MHSFM)/MH6S;
  ELSE IF SFAGE7=1 THEN ZMHI=(EM_T-MHSFM)/MH7S;
  ELSE IF SFAGE8=1 THEN ZMHI=(EM_T-MHSFM)/MH8S;
  ELSE IF SFAGE9=1 THEN ZMHI=(EM_T-MHSFM)/MH9S;
  ELSE IF SFAGE10=1 THEN ZMHI=(EM_T-MHSFM)/MH10S;
  ELSE IF SFAGE11=1 THEN ZMHI=(EM_T-MHSFM)/MH11S;
  ELSE IF SFAGE12=1 THEN ZMHI=(EM_T-MHSFM)/MH12S;
  ELSE IF SFAGE13=1 THEN ZMHI=(EM_T-MHSFM)/MH13S;
  ELSE IF SFAGE14=1 THEN ZMHI=(EM_T-MHSFM)/MH14S;

pcsSFM=(SFAGE1*pcs1)+(SFAGE2*pcs2)+(SFAGE3*pcs3)+
       (SFAGE4*pcs4)+ (SFAGE5*pcs5)+ (SFAGE6*pcs6)+
       (SFAGE7*pcs7)+ (SFAGE8*pcs8)+ (SFAGE9*pcs9)+
       (SFAGE10*pcs10)+ (SFAGE11*pcs11)+ (SFAGE12*pcs12) +
       (SFAGE13*pcs13) + (SFAGE14*pcs14);

IF SFAGE1=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs1S;
  ELSE IF SFAGE2=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs2S;
  ELSE IF SFAGE3=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs3S;
  ELSE IF SFAGE4=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs4S;
  ELSE IF SFAGE5=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs5S;
  ELSE IF SFAGE6=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs6S;
  ELSE IF SFAGE7=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs7S;
  ELSE IF SFAGE8=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs8S;
  ELSE IF SFAGE9=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs9S;
  ELSE IF SFAGE10=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs10S;
  ELSE IF SFAGE11=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs11S;
  ELSE IF SFAGE12=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs12S;
  ELSE IF SFAGE13=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs13S;
  ELSE IF SFAGE14=1 THEN Zpcs=(agg_phys_t-pcsSFM)/pcs14S;

mcsSFM=(SFAGE1*mcs1)+(SFAGE2*mcs2)+(SFAGE3*mcs3)+
       (SFAGE4*mcs4)+ (SFAGE5*mcs5)+ (SFAGE6*mcs6)+
       (SFAGE7*mcs7)+ (SFAGE8*mcs8)+ (SFAGE9*mcs9)+
       (SFAGE10*mcs10)+ (SFAGE11*mcs11)+ (SFAGE12*mcs12) +
       (SFAGE13*mcs13) + (SFAGE14*mcs14);

IF SFAGE1=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs1S;
  ELSE IF SFAGE2=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs2S;
  ELSE IF SFAGE3=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs3S;
  ELSE IF SFAGE4=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs4S;
  ELSE IF SFAGE5=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs5S;
  ELSE IF SFAGE6=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs6S;
  ELSE IF SFAGE7=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs7S;
  ELSE IF SFAGE8=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs8S;
  ELSE IF SFAGE9=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs9S;
  ELSE IF SFAGE10=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs10S;
  ELSE IF SFAGE11=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs11S;
  ELSE IF SFAGE12=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs12S;
  ELSE IF SFAGE13=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs13S;
  ELSE IF SFAGE14=1 THEN Zmcs=(agg_ment_t-mcsSFM)/mcs14S;

IF PHYFUN10=. THEN PFISFM=.;  IF PFISFM=.  THEN PHYFUN10=.;
IF ROLEP4=.   THEN RPSFM=.;   IF RPSFM=.   THEN ROLEP4=.;
IF PAIN2=.    THEN BPSFM=.;   IF BPSFM=.   THEN PAIN2=.;
                              IF BPSFM=.   THEN SFPAIN2=.;
IF GENH5=.    THEN GENSFM=.;  IF GENSFM=.  THEN GENH5=.;
                              IF GENSFM=.  THEN SFGENH5=.;
IF ENFAT4=.   THEN ENFTSFM=.; IF ENFTSFM=. THEN ENFAT4=.;
IF SOCFUN2=.  THEN SFSFM=.;   IF SFSFM=.   THEN SOCFUN2=.;
IF ROLEE3=.   THEN RESFM=.;   IF RESFM=.   THEN ROLEE3=.;
IF EMOT5=.    THEN MHSFM=.;   IF MHSFM=.   THEN EMOT5=.;

if agg_phys_t=. then pcssfm=.; if pcssfm=. then agg_phys_t=.;
if agg_ment_t=. then mcssfm=.; if mcssfm=. then agg_ment_t=.;

label pfisfm="Physical functioning (general pop.)";
label rpsfm="Role limitation physical (general pop.)";
label bpsfm="Pain (general pop.)";
label gensfm="General health (general pop.)";
label mhsfm="Emotional well being (general pop.)";
label resfm="Role limitation emotional (general pop.)";
label enftsfm="Energy (general pop.)";
label sfsfm="Social functioning (general pop.)";
label pcssfm="PCS (general pop.)";
label mcssfm="MCS (general pop.)";

label ZPHY10 = "New Z PHYFUN10 (diff between sample and US gen pop)";
label ZRP    = "New Z ROLEP4   (diff between sample and US gen pop)";
label ZBP    = "New Z SFPAIN2  (diff between sample and US gen pop)";
label ZGENH  = "New Z SFGENH5  (diff between sample and US gen pop)";
label ZENFT  = "New Z ENFAT4   (diff between sample and US gen pop)";
label ZSF    = "New Z SOCFUN2  (diff between sample and US gen pop)";
label ZRE    = "New Z ROLEE3   (diff between sample and US gen pop)";
label ZMHI   = "New Z EMOT5    (diff between sample and US gen pop)";
label Zpcs   = "New Z AGG_PHYS (diff between sample and US gen pop)";
label Zmcs   = "New Z AGG_MENT (diff between sample and US gen pop)";

run;

TITLE1 "SF36 V2 - AGE AND GENDER ADJUSTED SCORES";
PROC MEANS data=TEMP1;
VAR phyfun10 rolep4 sfpain2 pain2 sfgenh5 genh5 emot5 rolee3 socfun2 enfat4 
pfisfm rpsfm bpsfm gensfm mhsfm resfm sfsfm enftsfm pcssfm mcssfm;
run;

TITLE1 "SF36 V2 - TEST OF DIFF BETWEEN SF-36 SCORES IN THE SAMPLE AND U.S. GENERAL POP"; RUN;
proc means t prt data=TEMP1;
var
ZPHY10 ZRP zbp ZGENH ZMHI ZRE ZSF ZENFT zpcs zmcs;
run;