****************************************************;
data sf36b; set sf36a;

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;
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 AND MALE=1 THEN SFAGE6=1;
IF 18<=AGE<=24 AND MALE=0 THEN SFAGE7=1;
IF 24<AGE<=34 AND MALE=0 THEN SFAGE8=1;
IF 34<AGE<=44 AND MALE=0 THEN SFAGE9=1;
IF 44<AGE<=54 AND MALE=0 THEN SFAGE10=1;
IF 54<AGE<=64 AND MALE=0 THEN SFAGE11=1;
IF 64<AGE AND MALE=0 THEN SFAGE12=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    6-10 PF3   11-15 PF4   16-20 PF5   21-25 PF6   26-30 
PF7   31-35 PF8   36-40 PF9   41-45 PF10  46-50 PF11  51-55 PF12  56-60 
#2 PF1S 1-5 PF2S   6-10 PF3S  11-15 PF4S  16-20 PF5S  21-25 PF6S  26-30 
PF7S  31-35 PF8S  36-40 PF9S  41-45 PF10S 46-50 PF11S 51-55 PF12S 56-60 
#3 RP1  1-5 RP2    6-10 RP3   11-15 RP4   16-20 RP5   21-25 RP6   26-30 
RP7   31-35 RP8   36-40 RP9   41-45 RP10  46-50 RP11  51-55 RP12  56-60 
#4 RP1S 1-5 RP2S   6-10 RP3S  11-15 RP4S  16-20 RP5S  21-25 RP6S  26-30 
RP7S  31-35 RP8S  36-40 RP9S  41-45 RP10S 46-50 RP11S 51-55 RP12S 56-60 
#5 BP1  1-5 BP2    6-10 BP3   11-15 BP4   16-20 BP5   21-25 BP6   26-30 
BP7   31-35 BP8   36-40 BP9   41-45 BP10  46-50 BP11  51-55 BP12  56-60 
#6 BP1S 1-5 BP2S   6-10 BP3S  11-15 BP4S  16-20 BP5S  21-25 BP6S  26-30 
BP7S  31-35 BP8S  36-40 BP9S  41-45 BP10S 46-50 BP11S 51-55 BP12S 56-60 
#7 GEN1 1-5  GEN2   6-10  GEN3   11-15 GEN4   16-20 GEN5   21-25 GEN6   26-30
GEN7   31-35 GEN8   36-40 GEN9   41-45 GEN10  46-50 GEN11  51-55 GEN12  56-60
#8 GEN1S 1-5 GEN2S   6-10 GEN3S  11-15 GEN4S  16-20 GEN5S  21-25 GEN6S  26-30
GEN7S  31-35 GEN8S  36-40 GEN9S  41-45 GEN10S 46-50 GEN11S 51-55 GEN12S 56-60
#9 ENFT1 1-5  ENFT2    6-10  ENFT3   11-15  ENFT4   16-20 ENFT5   21-25 ENFT6   26-30 
ENFT7   31-35  ENFT8  36-40  ENFT9   41-45  ENFT10  46-50 ENFT11  51-55 ENFT12  56-60 
#10 ENFT1S 1-5 ENFT2S   6-10 ENFT3S  11-15 ENFT4S  16-20 ENFT5S  21-25 ENFT6S  26-30 
ENFT7S  31-35 ENFT8S  36-40 ENFT9S  41-45 ENFT10S 46-50 ENFT11S 51-55 ENFT12S 56-60 
#11SF1    1-5 SF2    6-10   SF3   11-15   SF4   16-20   SF5   21-25   SF6   26-30   
SF7   31-35   SF8   36-40   SF9   41-45   SF10  46-50   SF11  51-55   SF12  56-60   
#12 SF1S 1-5  SF2S   6-10   SF3S  11-15   SF4S  16-20   SF5S  21-25   SF6S  26-30   
SF7S  31-35   SF8S  36-40   SF9S  41-45   SF10S 46-50   SF11S 51-55   SF12S 56-60   
#13           RE1     1-5   RE2    6-10   RE3   11-15   RE4   16-20   RE5   21-25   RE6   26-30   
RE7   31-35   RE8   36-40   RE9   41-45   RE10  46-50   RE11  51-55   RE12  56-60   
#14           RE1S    1-5   RE2S   6-10   RE3S  11-15   RE4S  16-20   RE5S  21-25   RE6S  26-30   
RE7S  31-35   RE8S  36-40   RE9S  41-45   RE10S 46-50   RE11S 51-55   RE12S 56-60   
#15 MH1     1-5   MH2    6-10   MH3   11-15   MH4   16-20   MH5   21-25   MH6   26-30   
MH7   31-35   MH8   36-40   MH9   41-45   MH10  46-50   MH11  51-55   MH12  56-60   
#16           MH1S    1-5   MH2S   6-10   MH3S  11-15   MH4S  16-20   MH5S  21-25   MH6S  26-30   
MH7S  31-35   MH8S  36-40   MH9S  41-45   MH10S 46-50   MH11S 51-55   MH12S 56-60   ;
datalines;
94.1494.9091.3986.5079.8865.7990.1889.1288.0682.8673.0961.86
16.3011.4414.6820.3725.4728.3120.0418.7217.7021.7226.7328.95
93.5091.8689.7685.5876.0359.7284.9186.7383.6579.9371.6156.11
21.3921.0424.7530.2436.6642.5130.7327.9932.2135.3839.8442.53
79.6283.1079.3674.1868.5068.7682.0079.6174.8572.1466.6463.44
21.4718.2221.2124.8126.1025.3721.3120.9422.7423.3425.2627.12
76.9579.4077.5573.1666.5858.6276.4874.8074.2570.4862.8761.64
17.8717.1715.9217.8923.2722.0518.6617.2419.4420.5823.3722.08
65.4164.6665.5063.0563.0057.8059.7158.0459.4360.6258.0855.46
19.1118.9918.6720.4421.3822.5520.0920.8519.7221.3223.4223.51
86.0985.6688.5485.5483.5679.6681.7384.0683.0782.7179.4377.00
20.1819.8318.0922.8521.9626.0020.9821.6623.2720.8427.0227.69
87.4982.1585.5285.4281.1476.9478.6382.3280.0881.9279.5173.38
27.5031.7828.1229.2534.0237.4833.8631.3033.8833.3434.6439.66
78.0274.1376.9876.3876.8777.3771.5372.4573.3274.3673.4074.71
16.0517.2416.4217.6218.7117.4219.4418.6216.7918.0819.7419.88
;
RUN;

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

DATA TEST;
 IF _N_=1 THEN SET GENPOP;
 SET sf36b;
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); 
PFIS=(SFAGE1*PF1S*PF1S)+ (SFAGE2*PF2S*PF2S)+
      (SFAGE3*PF3S*PF3S)+ (SFAGE4*PF4S*PF4S)+
      (SFAGE5*PF5S*PF5S)+ (SFAGE6*PF6S*PF6S)+
      (SFAGE7*PF7S*PF7S)+ (SFAGE8*PF8S*PF8S)+
      (SFAGE9*PF9S*PF9S)+ (SFAGE10*PF10S*PF10S)+
      (SFAGE11*PF11S*PF11S)+ (SFAGE12*PF12S*PF12S);
IF SFAGE1=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF1S;
  ELSE IF SFAGE2=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF2S;
  ELSE IF SFAGE3=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF3S;
  ELSE IF SFAGE4=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF4S;
  ELSE IF SFAGE5=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF5S;
  ELSE IF SFAGE6=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF6S;
  ELSE IF SFAGE7=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF7S;
  ELSE IF SFAGE8=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF8S;
  ELSE IF SFAGE9=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF9S;
  ELSE IF SFAGE10=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF10S;
  ELSE IF SFAGE11=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF11S;
  ELSE IF SFAGE12=1 THEN ZPHY10=(PHYFUN10-PFISFM)/PF12S;
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); 
RPS= (SFAGE1*RP1S*RP1S)+ (SFAGE2*RP2S*RP2S)+
      (SFAGE3*RP3S*RP3S)+ (SFAGE4*RP4S*RP4S)+
      (SFAGE5*RP5S*RP5S)+ (SFAGE6*RP6S*RP6S)+
      (SFAGE7*RP7S*RP7S)+ (SFAGE8*RP8S*RP8S)+
      (SFAGE9*RP9S*RP9S)+ (SFAGE10*RP10S*RP10S)+
      (SFAGE11*RP11S*RP11S)+ (SFAGE12*RP12S*RP12S);
IF SFAGE1=1 THEN ZRP=(ROLEP4-RPSFM)/RP1S;
  ELSE IF SFAGE2=1 THEN ZRP=(ROLEP4-RPSFM)/RP2S;
  ELSE IF SFAGE3=1 THEN ZRP=(ROLEP4-RPSFM)/RP3S;
  ELSE IF SFAGE4=1 THEN ZRP=(ROLEP4-RPSFM)/RP4S;
  ELSE IF SFAGE5=1 THEN ZRP=(ROLEP4-RPSFM)/RP5S;
  ELSE IF SFAGE6=1 THEN ZRP=(ROLEP4-RPSFM)/RP6S;
  ELSE IF SFAGE7=1 THEN ZRP=(ROLEP4-RPSFM)/RP7S;
  ELSE IF SFAGE8=1 THEN ZRP=(ROLEP4-RPSFM)/RP8S;
  ELSE IF SFAGE9=1 THEN ZRP=(ROLEP4-RPSFM)/RP9S;
  ELSE IF SFAGE10=1 THEN ZRP=(ROLEP4-RPSFM)/RP10S;
  ELSE IF SFAGE11=1 THEN ZRP=(ROLEP4-RPSFM)/RP11S;
  ELSE IF SFAGE12=1 THEN ZRP=(ROLEP4-RPSFM)/RP12S;
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); 
BPS=(SFAGE1*BP1S*BP1S)+ (SFAGE2*BP2S*BP2S)+
      (SFAGE3*BP3S*BP3S)+ (SFAGE4*BP4S*BP4S)+
      (SFAGE5*BP5S*BP5S)+ (SFAGE6*BP6S*BP6S)+
      (SFAGE7*BP7S*BP7S)+ (SFAGE8*BP8S*BP8S)+
      (SFAGE9*BP9S*BP9S)+ (SFAGE10*BP10S*BP10S)+
      (SFAGE11*BP11S*BP11S)+ (SFAGE12*BP12S*BP12S);

IF SFAGE1=1 THEN ZBP=(SFPAIN-BPSFM)/BP1S;
  ELSE IF SFAGE2=1 THEN ZBP=(SFPAIN-BPSFM)/BP2S;
  ELSE IF SFAGE3=1 THEN ZBP=(SFPAIN-BPSFM)/BP3S;
  ELSE IF SFAGE4=1 THEN ZBP=(SFPAIN-BPSFM)/BP4S;
  ELSE IF SFAGE5=1 THEN ZBP=(SFPAIN-BPSFM)/BP5S;
  ELSE IF SFAGE6=1 THEN ZBP=(SFPAIN-BPSFM)/BP6S;
  ELSE IF SFAGE7=1 THEN ZBP=(SFPAIN-BPSFM)/BP7S;
  ELSE IF SFAGE8=1 THEN ZBP=(SFPAIN-BPSFM)/BP8S;
  ELSE IF SFAGE9=1 THEN ZBP=(SFPAIN-BPSFM)/BP9S;
  ELSE IF SFAGE10=1 THEN ZBP=(SFPAIN-BPSFM)/BP10S;
  ELSE IF SFAGE11=1 THEN ZBP=(SFPAIN-BPSFM)/BP11S;
  ELSE IF SFAGE12=1 THEN ZBP=(SFPAIN-BPSFM)/BP12S;
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);
GENS=(SFAGE1*GEN1S*GEN1S)+ (SFAGE2*GEN2S*GEN2S)+
      (SFAGE3*GEN3S*GEN3S)+ (SFAGE4*GEN4S*GEN4S)+
      (SFAGE5*GEN5S*GEN5S)+ (SFAGE6*GEN6S*GEN6S)+
      (SFAGE7*GEN7S*GEN7S)+ (SFAGE8*GEN8S*GEN8S)+
      (SFAGE9*GEN9S*GEN9S)+ (SFAGE10*GEN10S*GEN10S)+
      (SFAGE11*GEN11S*GEN11S)+ (SFAGE12*GEN12S*GEN12S);
IF SFAGE1=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN1S;
  ELSE IF SFAGE2=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN2S;
  ELSE IF SFAGE3=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN3S;
  ELSE IF SFAGE4=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN4S;
  ELSE IF SFAGE5=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN5S;
  ELSE IF SFAGE6=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN6S;
  ELSE IF SFAGE7=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN7S;
  ELSE IF SFAGE8=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN8S;
  ELSE IF SFAGE9=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN9S;
  ELSE IF SFAGE10=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN10S;
  ELSE IF SFAGE11=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN11S;
  ELSE IF SFAGE12=1 THEN ZGENH=(SFGENH5-GENSFM)/GEN12S;
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);
ENFTS=(SFAGE1*ENFT1S*ENFT1S)+ (SFAGE2*ENFT2S*ENFT2S)+
      (SFAGE3*ENFT3S*ENFT3S)+ (SFAGE4*ENFT4S*ENFT4S)+
      (SFAGE5*ENFT5S*ENFT5S)+ (SFAGE6*ENFT6S*ENFT6S)+
      (SFAGE7*ENFT7S*ENFT7S)+ (SFAGE8*ENFT8S*ENFT8S)+
      (SFAGE9*ENFT9S*ENFT9S)+ (SFAGE10*ENFT10S*ENFT10S)+
      (SFAGE11*ENFT11S*ENFT11S)+ (SFAGE12*ENFT12S*ENFT12S);
IF SFAGE1=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT1S;
  ELSE IF SFAGE2=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT2S;
  ELSE IF SFAGE3=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT3S;
  ELSE IF SFAGE4=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT4S;
  ELSE IF SFAGE5=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT5S;
  ELSE IF SFAGE6=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT6S;
  ELSE IF SFAGE7=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT7S;
  ELSE IF SFAGE8=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT8S;
  ELSE IF SFAGE9=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT9S;
  ELSE IF SFAGE10=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT10S;
  ELSE IF SFAGE11=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT11S;
  ELSE IF SFAGE12=1 THEN ZENFT=(ENFAT4-ENFTSFM)/ENFT12S;
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);      

SFS=(SFAGE1*SF1S*SF1S)+ (SFAGE2*SF2S*SF2S)+
      (SFAGE3*SF3S*SF3S)+ (SFAGE4*SF4S*SF4S)+
      (SFAGE5*SF5S*SF5S)+ (SFAGE6*SF6S*SF6S)+
      (SFAGE7*SF7S*SF7S)+ (SFAGE8*SF8S*SF8S)+
      (SFAGE9*SF9S*SF9S)+ (SFAGE10*SF10S*SF10S)+
      (SFAGE11*SF11S*SF11S)+ (SFAGE12*SF12S*SF12S);
IF SFAGE1=1 THEN ZSF=(SOCFUN2-SFSFM)/SF1S;
  ELSE IF SFAGE2=1 THEN ZSF=(SOCFUN2-SFSFM)/SF2S;
  ELSE IF SFAGE3=1 THEN ZSF=(SOCFUN2-SFSFM)/SF3S;
  ELSE IF SFAGE4=1 THEN ZSF=(SOCFUN2-SFSFM)/SF4S;
  ELSE IF SFAGE5=1 THEN ZSF=(SOCFUN2-SFSFM)/SF5S;
  ELSE IF SFAGE6=1 THEN ZSF=(SOCFUN2-SFSFM)/SF6S;
  ELSE IF SFAGE7=1 THEN ZSF=(SOCFUN2-SFSFM)/SF7S;
  ELSE IF SFAGE8=1 THEN ZSF=(SOCFUN2-SFSFM)/SF8S;
  ELSE IF SFAGE9=1 THEN ZSF=(SOCFUN2-SFSFM)/SF9S;
  ELSE IF SFAGE10=1 THEN ZSF=(SOCFUN2-SFSFM)/SF10S;
  ELSE IF SFAGE11=1 THEN ZSF=(SOCFUN2-SFSFM)/SF11S;
  ELSE IF SFAGE12=1 THEN ZSF=(SOCFUN2-SFSFM)/SF12S;
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);      
RES=(SFAGE1*RE1S*RE1S)+ (SFAGE2*RE2S*RE2S)+
      (SFAGE3*RE3S*RE3S)+ (SFAGE4*RE4S*RE4S)+
      (SFAGE5*RE5S*RE5S)+ (SFAGE6*RE6S*RE6S)+
      (SFAGE7*RE7S*RE7S)+ (SFAGE8*RE8S*RE8S)+
      (SFAGE9*RE9S*RE9S)+ (SFAGE10*RE10S*RE10S)+
      (SFAGE11*RE11S*RE11S)+ (SFAGE12*RE12S*RE12S);
IF SFAGE1=1 THEN ZRE=(ROLEE3-RESFM)/RE1S;
  ELSE IF SFAGE2=1 THEN ZRE=(ROLEE3-RESFM)/RE2S;
  ELSE IF SFAGE3=1 THEN ZRE=(ROLEE3-RESFM)/RE3S;
  ELSE IF SFAGE4=1 THEN ZRE=(ROLEE3-RESFM)/RE4S;
  ELSE IF SFAGE5=1 THEN ZRE=(ROLEE3-RESFM)/RE5S;
  ELSE IF SFAGE6=1 THEN ZRE=(ROLEE3-RESFM)/RE6S;
  ELSE IF SFAGE7=1 THEN ZRE=(ROLEE3-RESFM)/RE7S;
  ELSE IF SFAGE8=1 THEN ZRE=(ROLEE3-RESFM)/RE8S;
  ELSE IF SFAGE9=1 THEN ZRE=(ROLEE3-RESFM)/RE9S;
  ELSE IF SFAGE10=1 THEN ZRE=(ROLEE3-RESFM)/RE10S;
  ELSE IF SFAGE11=1 THEN ZRE=(ROLEE3-RESFM)/RE11S;
  ELSE IF SFAGE12=1 THEN ZRE=(ROLEE3-RESFM)/RE12S;
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);      
MHS=(SFAGE1*MH1S*MH1S)+ (SFAGE2*MH2S*MH2S)+
      (SFAGE3*MH3S*MH3S)+ (SFAGE4*MH4S*MH4S)+
      (SFAGE5*MH5S*MH5S)+ (SFAGE6*MH6S*MH6S)+
      (SFAGE7*MH7S*MH7S)+ (SFAGE8*MH8S*MH8S)+
      (SFAGE9*MH9S*MH9S)+ (SFAGE10*MH10S*MH10S)+
      (SFAGE11*MH11S*MH11S)+ (SFAGE12*MH12S*MH12S);
IF SFAGE1=1 THEN ZMHI=(EMOT5-MHSFM)/MH1S;
  ELSE IF SFAGE2=1 THEN ZMHI=(EMOT5-MHSFM)/MH2S;
  ELSE IF SFAGE3=1 THEN ZMHI=(EMOT5-MHSFM)/MH3S;
  ELSE IF SFAGE4=1 THEN ZMHI=(EMOT5-MHSFM)/MH4S;
  ELSE IF SFAGE5=1 THEN ZMHI=(EMOT5-MHSFM)/MH5S;
  ELSE IF SFAGE6=1 THEN ZMHI=(EMOT5-MHSFM)/MH6S;
  ELSE IF SFAGE7=1 THEN ZMHI=(EMOT5-MHSFM)/MH7S;
  ELSE IF SFAGE8=1 THEN ZMHI=(EMOT5-MHSFM)/MH8S;
  ELSE IF SFAGE9=1 THEN ZMHI=(EMOT5-MHSFM)/MH9S;
  ELSE IF SFAGE10=1 THEN ZMHI=(EMOT5-MHSFM)/MH10S;
  ELSE IF SFAGE11=1 THEN ZMHI=(EMOT5-MHSFM)/MH11S;
  ELSE IF SFAGE12=1 THEN ZMHI=(EMOT5-MHSFM)/MH12S;

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 SFPAIN=.;                        
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=.;

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.)";
RUN;
*****************************************************;      

DATA TEST;SET TEST;RUN;
PROC MEANS;                                                 
VAR                                                         
PHYFUN10 ROLEP4 PAIN2 SFPAIN GENH5 SFGENH5
EMOT5 ROLEE3 ENFAT4 SOCFUN2;RUN;
PROC MEANS N MEAN;                                          
VAR                                                         
PFISFM RPSFM BPSFM GENSFM
MHSFM RESFM ENFTSFM SFSFM;RUN;
*****************************************************;      
PROC MEANS T PRT;                                           
 VAR ZPHY10 ZRP ZBP ZGENH ZENFT ZSF ZRE ZMHI;RUN;