* SAS CODE FOR SCORING 36-ITEM HEALTH SURVEY 1.0
* WRITTEN BY RON D. HAYS, RAND, 310-393-0411 (EXT. 7581) ***;
DATA TEMP1;
 SET TEMP;
RENAME
I1=I1
I2=I2
I3=I3
I4=I4
I5=I5
I6=I6
I7=I7
I8=I8
I9=I9
I10=I10
I11=I11
I12=I12
I13=I13
I14=I14
I15=I15
I16=I16
I17=I17
I18=I18
I19=I19
I20=I20
I21=I21
I22=I22
I23=I23
I24=I24
I25=I25
I26=I26
I27=I27
I28=I28
I29=I29
I30=I30
I31=I31
I32=I32
I33=I33
I34=I34
I35=I35
I36=I36;RUN;
*****************************************************************;
DATA TEMP1;SET TEMP1;
ARRAY RFIVEPT (I) I1 I2 I20 I22 I34 I36;
ARRAY THREEPT (I) I3 I4 I5 I6 I7 I8 I9 I10 I11 I12;
ARRAY TWOPT   (I) I13 I14 I15 I16 I17 I18 I19;
ARRAY RSIXPT  (I) I21 I23 I26 I27 I30;
ARRAY SIXPT   (I) I24 I25 I28 I29 I31;
ARRAY FIVEPT  (I) I32 I33 I35;
*****************************************************************;
I1SF=I1;I21SF=I21;I22SF=I22;
DO OVER RFIVEPT;
 IF RFIVEPT=1 THEN RFIVEPT=100;
 ELSE IF RFIVEPT=2 THEN RFIVEPT=75;
 ELSE IF RFIVEPT=3 THEN RFIVEPT=50;
 ELSE IF RFIVEPT=4 THEN RFIVEPT=25;
 ELSE IF RFIVEPT=5 THEN RFIVEPT=0;END;
DO OVER THREEPT;
 IF THREEPT=1 THEN THREEPT=0;
 ELSE IF THREEPT=2 THEN THREEPT=50;
 ELSE IF THREEPT=3 THEN THREEPT=100;END;
DO OVER TWOPT;
 IF TWOPT=1 THEN TWOPT=0;
 ELSE IF TWOPT=2 THEN TWOPT=100;END;
DO OVER RSIXPT;
 IF RSIXPT=1 THEN RSIXPT=100;
 ELSE IF RSIXPT=2 THEN RSIXPT=80;
 ELSE IF RSIXPT=3 THEN RSIXPT=60;
 ELSE IF RSIXPT=4 THEN RSIXPT=40;
 ELSE IF RSIXPT=5 THEN RSIXPT=20;
 ELSE IF RSIXPT=6 THEN RSIXPT=0;END;
DO OVER SIXPT;
 IF SIXPT=1 THEN SIXPT=0;
 ELSE IF SIXPT=2 THEN SIXPT=20;
 ELSE IF SIXPT=3 THEN SIXPT=40;
 ELSE IF SIXPT=4 THEN SIXPT=60;
 ELSE IF SIXPT=5 THEN SIXPT=80;
 ELSE IF SIXPT=6 THEN SIXPT=100;END;
DO OVER FIVEPT;
 IF FIVEPT=1 THEN FIVEPT=0;
 ELSE IF FIVEPT=2 THEN FIVEPT=25;
 ELSE IF FIVEPT=3 THEN FIVEPT=50;
 ELSE IF FIVEPT=4 THEN FIVEPT=75;
 ELSE IF FIVEPT=5 THEN FIVEPT=100;END;
*****************************************************************;
IF I1SF=1 THEN I1SF=5.0;
 ELSE IF I1SF=2 THEN I1SF=4.4;
 ELSE IF I1SF=3 THEN I1SF=3.4;
 ELSE IF I1SF=4 THEN I1SF=2.0;
 ELSE IF I1SF=5 THEN I1SF=1.0;
I1SF=(I1SF-1)*25;
IF I21SF>.Z AND I22SF>.Z THEN DO;
 IF I22SF=1 AND I21SF=1 THEN I22SF=6;
   ELSE IF I22SF=1 AND 7>I21SF>1 THEN I22SF=5;
   ELSE IF I22SF=2 AND 7>I21SF>0 THEN I22SF=4;
   ELSE IF I22SF=3 AND 7>I21SF>0 THEN I22SF=3;
   ELSE IF I22SF=4 AND 7>I21SF>0 THEN I22SF=2;
   ELSE IF I22SF=5 AND 7>I21SF>0 THEN I22SF=1;END;
IF I21SF<=.Z AND I22SF>.Z THEN DO;
 IF I22SF=1 THEN I22SF=6.0;
  ELSE IF I22SF=2 THEN I22SF=4.75;
  ELSE IF I22SF=3 THEN I22SF=3.5;
  ELSE IF I22SF=4 THEN I22SF=2.25;
  ELSE IF I22SF=5 THEN I22SF=1.0;END;
IF I21SF=1 THEN I21SF=6.0;
 ELSE IF I21SF=2 THEN I21SF=5.4;
 ELSE IF I21SF=3 THEN I21SF=4.2;
 ELSE IF I21SF=4 THEN I21SF=3.1;
 ELSE IF I21SF=5 THEN I21SF=2.2;
 ELSE IF I21SF=6 THEN I21SF=1.0;
I21SF=(I21SF-1)*20;I22SF=(I22SF-1)*20;
***************************************************;
PHYFUN10=MEAN(I3,I4,I5,I6,I7,I8,I9,I10,I11,I12);
ROLEP4=MEAN(I13,I14,I15,I16);
PAIN2=MEAN(I21,I22);SFPAIN=MEAN(I21SF,I22SF);
GENH5=MEAN(I1,I33,I34,I35,I36);
SFGENH5=MEAN(I1SF,I33,I34,I35,I36);
EMOT5=MEAN(I24,I25,I26,I28,I30);
ROLEE3=MEAN(I17,I18,I19);
SOCFUN2=MEAN(I20,I32);
ENFAT4=MEAN(I23,I27,I29,I31);RUN;
****************************************************;
DATA TEMP2;
 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;
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;
*********************************************************;
DATA GENPOP;
INFILE 'sf36.raw' MISSOVER;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   ;RUN;
*****************************;
DATA TEST;
 IF _N_=1 THEN SET GENPOP;
 SET TEMP2;
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); 
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); 
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); 
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);
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);
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);      
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);      
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);      
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=.;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;
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR                                  
I3 I4 I5 I6 I7 I8 I9 I10 I11 I12;                           
TITLE 'PHYSICAL FUNCTIONING';RUN;                           
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR                                  
I13 I14 I15 I16;                                            
TITLE 'ROLE LIMITATIONS--PHYSICAL';RUN;                     
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR                                  
I21 I22;                                                    
TITLE 'PAIN--RAND SCORING';RUN;                             
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR
I21SF I22SF;
TITLE 'PAIN--NEMC SCORING';RUN;
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR
I1 I33 I34 I35 I36;
TITLE 'GENERAL HEALTH--RAND SCORING';RUN;
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR                                  
I1SF I33 I34 I35 I36;                                       
TITLE 'GENERAL HEALTH--NEMC SCORING';RUN;                   
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR                                  
I24 I25 I26 I28 I30;                                        
TITLE 'EMOTIONAL WELL-BEING';RUN;                           
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR                                  
I17 I18 I19 ;                                               
TITLE 'ROLE LIMITATIONS--EMOTIONAL';RUN;                    
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR                                  
I20 I32;                                                    
TITLE 'SOCIAL FUNCTION';RUN;                                
*****************************************************;      
PROC CORR NOMISS ALPHA;VAR                                  
I23 I27 I29 I31;                                            
TITLE 'ENERGY';RUN;                                         
*****************************************************;   

*****************************************************************;
DATA TEMPNEW;
 SET TEMP1;
*****************************************************************;
*** 1) Transform SF-36 scores (NEMC Scoring) to z-scores: ;
   PF_Z = (PHYFUN10 - 84.52404) / 22.89490 ;
   RP_Z = (ROLEP4   - 81.19907) / 33.79729 ;
   BP_Z = (SFPAIN   - 75.49196) / 23.55879 ;
   GH_Z = (SFGENH5  - 72.21316) / 20.16964 ;
   EM_Z = (EMOT5    - 74.84212) / 18.01189 ;
   RE_Z = (ROLEE3   - 81.29467) / 33.02717 ;
   SF_Z = (SOCFUN2  - 83.59753) / 22.37642 ;
   EN_Z = (ENFAT4   - 61.05453) / 20.86942 ;
*****************************************************************;
*** 2) Create physical and mental health composite scores: ;
   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);
*****************************************************************;
*** 3) Transform composite and scale scores to T-scores: ;
   AGG_PHYS = 50 + (AGG_PHYS * 10);
   AGG_MENT = 50 + (AGG_MENT * 10);
   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) ;
*****************************************************************;
*** B. CREATING NEMC SF-12 COMPOSITE SCORES;
*** Create dummy variables for the SF-12 items as indicated below: ;
IF I1=0 THEN GH1_1=1;
 ELSE IF I1>=0 THEN GH1_1=0;
IF I1=25 THEN GH1_2=1;
 ELSE IF I1>=0 THEN GH1_2=0;
IF I1=50 THEN GH1_3=1;
 ELSE IF I1>=0 THEN GH1_3=0;
IF I1=75 THEN GH1_4=1;
 ELSE IF I1>=0 THEN GH1_4=0;
IF I4=0 THEN PF02_1=1;
 ELSE IF I4>=0 THEN PF02_1=0;
IF I4=50 THEN PF02_2=1;
 ELSE IF I4>=0 THEN PF02_2=0;
IF I6=0 THEN PF04_1=1;
 ELSE IF I6>=0 THEN PF04_1=0;
IF I6=50 THEN PF04_2=1;
 ELSE IF I6>=0 THEN PF04_2=0;
IF I14=0 THEN RP2_1=1;
 ELSE IF I14>=0 THEN RP2_1=0;
IF I15=0 THEN RP3_1=1;
 ELSE IF I15>=0 THEN RP3_1=0;
IF I18=0 THEN RE2_1=1;
 ELSE IF I18>=0 THEN RE2_1=0;
IF I19=0 THEN RE3_1=1;
 ELSE IF I19>=0 THEN RE3_1=0;
IF I22=0 THEN BP2_1=1;
 ELSE IF I22>=0 THEN BP2_1=0;
IF I22=25 THEN BP2_2=1;
 ELSE IF I22>=0 THEN BP2_2=0;
IF I22=50 THEN BP2_3=1;
 ELSE IF I22>=0 THEN BP2_3=0;
IF I22=75 THEN BP2_4=1;
 ELSE IF I22>=0 THEN BP2_4=0;
IF I26=0 THEN EM3_1=1;
 ELSE IF I26>=0 THEN EM3_1=0;
IF I26=20 THEN EM3_2=1;
 ELSE IF I26>=0 THEN EM3_2=0;
IF I26=40 THEN EM3_3=1;
 ELSE IF I26>=0 THEN EM3_3=0;
IF I26=60 THEN EM3_4=1;
 ELSE IF I26>=0 THEN EM3_4=0;
IF I26=80 THEN EM3_5=1;
 ELSE IF I26>=0 THEN EM3_5=0;
IF I27=0 THEN EN2_1=1;
 ELSE IF I27>=0 THEN EN2_1=0;
IF I27=20 THEN EN2_2=1;
 ELSE IF I27>=0 THEN EN2_2=0;
IF I27=40 THEN EN2_3=1;
 ELSE IF I27>=0 THEN EN2_3=0;
IF I27=60 THEN EN2_4=1;
 ELSE IF I27>=0 THEN EN2_4=0;
IF I27=80 THEN EN2_5=1;
 ELSE IF I27>=0 THEN EN2_5=0;
IF I28=0 THEN EM4_1=1;
 ELSE IF I28>=0 THEN EM4_1=0;
IF I28=20 THEN EM4_2=1;
 ELSE IF I28>=0 THEN EM4_2=0;
IF I28=40 THEN EM4_3=1;
 ELSE IF I28>=0 THEN EM4_3=0;
IF I28=60 THEN EM4_4=1;
 ELSE IF I28>=0 THEN EM4_4=0;
IF I28=80 THEN EM4_5=1;
 ELSE IF I28>=0 THEN EM4_5=0;
IF I32=0 THEN SF2_1=1;
 ELSE IF I32>=0 THEN SF2_1=0;
IF I32=25 THEN SF2_2=1;
 ELSE IF I32>=0 THEN SF2_2=0;
IF I32=50 THEN SF2_3=1;
 ELSE IF I32>=0 THEN SF2_3=0;
IF I32=75 THEN SF2_4=1;
 ELSE IF I32>=0 THEN SF2_4=0;
*****************************************************************;
*** Then create SF-12 aggregates as follows: ;
   RAWPCS12 = (PF02_1 *  -7.23216) + (PF02_2 * -3.45555) +
              (PF04_1 *  -6.24397) + (PF04_2 * -2.73557) +
              (RP2_1  *  -4.61617) + (RP3_1  * -5.51747) +
              (BP2_1  * -11.25544) + (BP2_2  * -8.38063) +
              (BP2_3  *  -6.50522) + (BP2_4  * -3.80130) +
              (GH1_1  *  -8.37399) + (GH1_2  * -5.56461) +
              (GH1_3  *  -3.02396) + (GH1_4  * -1.31872) +
              (EN2_1  *  -2.44706) + (EN2_2  * -2.02168) +
              (EN2_3  *  -1.61850) + (EN2_4  * -1.14387) +
              (EN2_5  *  -0.42251) + (SF2_1  * -0.33682) +
              (SF2_2  *  -0.94342) + (SF2_3  * -0.18043) +
              (SF2_4  *   0.11038) + (RE2_1  *  3.04365) +
              (RE3_1  *   2.32091) + (EM3_1  *  3.46638) +
              (EM3_2  *   2.90426) + (EM3_3  *  2.37241) +
              (EM3_4  *   1.36689) + (EM3_5  *  0.66514) +
              (EM4_1  *   4.61446) + (EM4_2  *  3.41593) +
              (EM4_3  *   2.34247) + (EM4_4  *  1.28044) +
              (EM4_5  *   0.41188);
   RAWMCS12 = (PF02_1 *   3.93115) + (PF02_2 *   1.86840) +
              (PF04_1 *   2.68282) + (PF04_2 *   1.43103) +
              (RP2_1  *   1.44060) + (RP3_1  *   1.66968) +
              (BP2_1  *   1.48619) + (BP2_2  *   1.76691) +
              (BP2_3  *   1.49384) + (BP2_4  *   0.90384) +
              (GH1_1  *  -1.71175) + (GH1_2  *  -0.16891) +
              (GH1_3  *   0.03482) + (GH1_4  *  -0.06064) +
              (EN2_1  *  -6.02409) + (EN2_2  *  -4.88962) +
              (EN2_3  *  -3.29805) + (EN2_4  *  -1.65178) +
              (EN2_5  *  -0.92057) + (SF2_1  *  -6.29724) +
              (SF2_2  *  -8.26066) + (SF2_3  *  -5.63286) +
              (SF2_4  *  -3.13896) + (RE2_1  *  -6.82672) +
              (RE3_1  *  -5.69921) + (EM3_1  * -10.19085) +
              (EM3_2  *  -7.92717) + (EM3_3  *  -6.31121) +
              (EM3_4  *  -4.09842) + (EM3_5  *  -1.94949) +
              (EM4_1  * -16.15395) + (EM4_2  * -10.77911) +
              (EM4_3  *  -8.09914) + (EM4_4  *  -4.59055) +
              (EM4_5  *  -1.95934);
*****************************************************************;
*** Finally, transform the aggregates as follows: ;
   RPCS12 = RAWPCS12 + 56.57706 ;
   RMCS12 = RAWMCS12 + 60.75781 ;
run;
*****************************************************************;
PROC MEANS;                                                 
VAR                                                         
PHYFUN10 PF_T ROLEP4 RP_T
SFPAIN BP_T SFGENH5 GH_T
EMOT5 EM_T ROLEE3 RE_T
SOCFUN2 SF_T ENFAT4 EN_T
AGG_PHYS AGG_MENT;
run;
*****************************************************************;