/*********************************************************************************************
                                                                                      10/01/13

AARP_PLCO_OvCa_RAM_Model2: AARP PLCO (Ov)ary (Ca)ncer (R)isk (A)ssessment (M)acro (Model3)

RR model SAS prog is M:\Sas.Progs\OvBrEndo.Ca\RelRisk__122711\OvarianRR_1228_2011.sas

Model 3  code is derived from RelRisk___Final\OvarCa\AARP_PLCO_OvCa_RAM_Model2  with inclusion
of African-American EnCa Incidences and Competing risks          (e-mail R Pfeiffer 10/01/2013)

SAS macro to project for OvCa abs risk for white women based on the relative risk model 2
from a joint AARP/PLCO data set  (SAS transport file riskmodel.pee.sep08.d021810.cpt)
**********************************************************************************************/

option   nocenter  ls=115  ps=9999  notes;
OPTIONS  FORMCHAR="|----|+|---+=|-/\<>*";

/*
        AARP_PLCO_OvCa_RAM_Model3  SAS macro which performs OvCa absolute risk projection

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        Modification/change of any code from this point onward should be avoided,
        Any changes to these codes are done at the user's risk, since changes may
        inadvertenly cause the macro to be fundamentally altered resulting in incorrect
        projections and/or abnormal termination

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/

***                                macro                     upon invocation all macro parameters need to point;
***                                parameters                to appropriate sas file or sas variable names or constants;

%macro  AARP_PLCO_OvCa_RAM_Model3 (SAS_File                  =,

                                   Woman_ID                  =,

                                   T1                        =,
                                   T2                        =,

                                   Invrs_OC_Model            =,
                                   Invrs_Parity_Model        =,
                                   Horm_Model                =,
                                   FHbreast_Model            =,

                                   Race                      =,
                                   CharRace                  =,

                                   AbsRsk                    =);

/*
       SAS_File                  points to a sas system file which contains rr covariates for women under
                                 investiation i.e. white women whom we wish to project absolute risk based
                                 on their relative risk covariate values, initial age and projection age.
                                 This file (i.e. SAS_File) must be created prior to involking this SAS macro

       Woman_ID                  Woman's unique ID

       T1                        points to SAS variable which contains woman's current age
                                 valid ages are   T1 >= 50

       T2                        points to SAS variable which contains women's projection age
                                 valid ages are   T1  < T2  <= 90


                                 ***  constraint on T1 (current age) and T2 (projection age)   ***
                                 ***                     !!!!!!!!!!!!!!!!!!!                   !!!
                                 !!!                     50 <= T1 < T2 <= 90                   !!!
                                 !!!                     !!!!!!!!!!!!!!!!!!!                   !!!


       OC_Model                  points to SAS variable which contains Oral Contraceptive use
                                 OC_Model         0=   >1
                                                  1=  0,1

       Parity_Model              points to SAS variable which contains inverse Parity at BFC
                                 Parity_Model     0=  >=3
                                                  1=  1,2
                                                  2=    0

       Horm_Model                points to SAS variable which contains duration of HRT
                                 Horm_Model       0=   0y
                                                  1= <10y
                                                  2=  10y+

       FHbreast_Model            points to SAS variable which contains family history of BrCa OvCa
                                 FHbreast_Model   0=  no
                                                  1= yes

       Race                      points to SAS variable which contains race of subject
                                 Race         1=White                  (SEER13 1992-2006 OvCa incidence)
                                              2=African-American       (rateBLACKovariancancer 100113.xls  e-mail R Pfeiffer)

                                              3=Hispanic                Future implementation. Invalid for this version
                                              4=Other (Natv Amrn, Unk)  Future implementation. Invalid for this version

                                              5=???                     Future implementation. Invalid for this version.

                                              6=Asian/Pacific Islander  Future implementation. Invalid for this version


       Previous listed variables are required inputs to               SAS Macro  AARP_PLCO_OvCa_RAM_Model3



       Following variables are created and returned by                SAS Macro  AARP_PLCO_OvCa_RAM_Model3

       CharRace                  points to SAS variable which contains race as a character variable for each subject
                                 CharRace     " White"
                                              "AfrAmr"


       AbsRsk (%)                points to SAS variable which contains the projected abs risk in %
                                 Absolute Risk is from Ovarian Cancer model 3
*/

   data  TmpFile;      *** temporary working sas file containing rr covariate data;
   set  &SAS_File;     *** original  input   sas file containing rr covariate data;


         title3 'AARP_PLCO_OvCa_RAM_Model3  sas macro for OvCa absolute risk based on PLCO/AARP OvCa Model 3';

                 SEQ_Num = _n_;

                 Error_Ind = 0;                        *** error in input file indicator;
         label   Error_Ind = "If mean not 0, implies ERROR in file  -----> ";


         ***  constrant on  T1 (current age)  and  T2 (projection age)
         !!!                                                           !!!
         !!!                  !!!!!!!!!!!!!!!!!!!                      !!!
         !!!                  50 <= T1 < T2 <= 90                      !!!
         !!!                  !!!!!!!!!!!!!!!!!!!                      !!!;


         *** codes to test for consistency of T1 (initial age) and T2 (projection age);
         set_T1_Missing = &T1;
         set_T2_Missing = &T2;

         if (&T1 lt 50) then do;                        *** current    age must be ge 50;
            set_T1_Missing = .;
            Error_Ind      = 1;
         end;

         if (&T2 gt 90) then do;                        *** projection age must ge le 90;
            set_T2_Missing = .;
            Error_Ind      = 1;
         end;

         if (&T1 ge &T2) then do;       *** cuurent age must be less than projection age;
            set_T1_Missing = .;
            set_T2_Missing = .;
            Error_Ind      = 1;
         end;


         *** error checking on race code;

         RacCat = 1;
         if (&Race ne 1 and  &Race ne 2) then  RacCat = .;


         *** making 6 character labels for race code;

                                   CharRace = "Invald";
         if     (&Race eq  1) then CharRace = " White";    *** white SEER13 1992-2006 BrCa Rate;
         else if(&Race eq  2) then CharRace = "AfrAmr";    *** african-american;


         *** RR covariates have already been re-coded to integers 0, 1, 2 ...;

         label  SEQ_Num = "Sequence number of woman on data file"

                I_OC    = "Set to SAS missing value . when Invrs_OC_Model has range error"
                I_Par   = "Set to SAS missing value . when Invrs_Parity has range error"
                Horm    = "Set to SAS missing value . when Horm_Model has range error"
                FamHist = "Set to SAS missing value . when Family History Model has range error";



         if      (&Invrs_OC_Model    eq  0) then  I_OC    =0;
         else if (&Invrs_OC_Model    eq  1) then  I_OC    =1;
         else                                     I_OC    =.;

         if      (&Invrs_Parity_Model eq 0) then  I_Par   =0;
         else if (&Invrs_Parity_Model eq 1) then  I_Par   =1;
         else if (&Invrs_Parity_Model eq 2) then  I_Par   =2;
         else                                     I_Par   =.;

         if      (&Horm_Model         eq 0) then  Horm    =0;
         else if (&Horm_Model         eq 1) then  Horm    =1;
         else if (&Horm_Model         eq 2) then  Horm    =2;
         else                                     Horm    =.;

         if      (&FHbreast_Model     eq 0) then  FamHist =0;
         else if (&FHbreast_Model     eq 1) then  FamHist =1;
         else                                     FamHist =.;

         if (RacCat   eq  . or
             I_OC     eq  . or
             I_Par    eq  . or
             Horm     eq  . or
             FamHist  eq  .)   then  Error_Ind =1;

         Key = 1;
   run;




   ***   set up h1*, h2, beta & F(t) with known constants used in the nci OvCa risk disk;

   data  H1_Star;                                  *** h1star, OvCa composite incidences;

         array  Ages     (II)  A1-A8
        (50, 55, 60, 65, 70, 75, 80, 85);


         array  White_H1 (II)  WH1_1-WH1_8
        (0.0003220380, 0.0004160835, 0.0005927781, 0.0007061187, 0.0007312445,
         0.0008158844, 0.0008503896, 0.0006510022);            *** SEER13 1992-2006;

         array  Black_H1 (II)   BH1_1-BH1_8
        (0.0003220380, 0.0004160835, 0.0005927781, 0.0007061187, 0.0007312445,
         0.0008158844, 0.0008503896, 0.0006510022);            *** rateBLACKovariancancer 100113.xls;

         BH1_1 = 19.89561/100000;
         BH1_2 = 24.07111/100000;
         BH1_3 = 37.75996/100000;
         BH1_4 = 50.52974/100000;
         BH1_5 = 57.32873/100000;
         BH1_6 = 59.36862/100000;
         BH1_7 = 52.83730/100000;
         BH1_8 = 61.51584/100000;

         II  = .;
         Key = 1;
   run;


   data  H2;                                                   *** h2, Competing hazards;

         array  White_H2 (II)  WH2_1-WH2_8
        (0.0031966, 0.0050084 ,0.0083380, 0.0134493, 0.0217030,
          0.0346823, 0.0588216, 0.1393919);                    *** NCHS US mortality 1980-2006;

         array  Black_H2 (II)   BH2_1-BH2_8;

         BH2_1 =   702.39/100000;
         BH2_2 =  1011.11/100000;
         BH2_3 =  1459.42/100000;
         BH2_4 =  2128.44/100000;
         BH2_5 =  3097.99/100000;
         BH2_6 =  4494.24/100000;
         BH2_7 =  6819.83/100000;
         BH2_8 = 13376.92/100000;

         II  = .;
         Key = 1;
   run;


   data  LN_RR;                                           *** OvCa RR Model 2 Reduced model;
                                                          *** beta from 041211=062810;

         array  White_Beta (JJ)  I_OC_Beta
                                 I_Parity_Beta
                                 Horm_Beta
                                 FH_Beta
                                (0.30849706149924,
                                 0.22099240056796,
                                 0.23168424692686,
                                 0.23714258378071);                *** lnRR2;

         array  Beta_Name (JJ) $ CBeta1-CBeta4 ('OralCont ',
                                                'Parity   ',
                                                'Dura HRT ',
                                                'FamHstCa ');

         JJ  = .;
         Key = 1;
   run;


   data  FofT;                                            *** 1-Attributable Risk = F(t);

         White_1_AR = 0.573220847;                        *** N/sum(RR due rr covarates only);

         Key = 1;
   run;




   ***   The following 5 data steps, gathers all the needed parameters/constants
         and the input data set together to get ready for risk projection;

   data  TmpFile1;
   merge TmpFile  H1_Star;
   by    Key;
   run;


   data  TmpFile2;
   merge TmpFile1  H2;
   by    Key;
   run;


   data  TmpFile3;
   merge TmpFile2  LN_RR;
   by    Key;
   run;


   data  TmpFile4 (drop=Key);
   merge TmpFile3 FofT;
   by    Key;
   run;


   data  TmpFile;
   set   TmpFile4;

         array  White_H1  (II)    WH1_1-WH1_8;     *** white  h1star, OvCa composite incidences;
         array  White_H2  (II)    WH2_1-WH2_8;     *** white  h2,     Competing hazards;


         array  Black_H1  (II)    BH1_1-BH1_8;     *** black  h1star, OvCa composite incidences;
         array  Black_H2  (II)    BH2_1-BH2_8;     *** black  h2,     Competing hazards;


         array  Ages      (II)    A1-A8;
         array  AgesP5    (II)    AP1-AP8;


         do II = 1 to 8;
           AgesP5 = Ages + 5;
         end;


         array  White_Beta (JJ)  I_OC_Beta     I_Parity_Beta     Horm_Beta   FH_Beta;


         *** arrays to hold each 5yr age cat rate for each year in the 5yr age cat;
         array  WrkH1_1    (I5)  W1_01_1-W1_01_5;                            *** [50:55);
         array  WrkH1_2    (I5)  W1_02_1-W1_02_5;                            *** [55:60);
         array  WrkH1_3    (I5)  W1_03_1-W1_03_5;                            *** [60:65);
         array  WrkH1_4    (I5)  W1_04_1-W1_04_5;                            *** [65:70);
         array  WrkH1_5    (I5)  W1_05_1-W1_05_5;                            *** [70:75);
         array  WrkH1_6    (I5)  W1_06_1-W1_06_5;                            *** [75:80);
         array  WrkH1_7    (I5)  W1_07_1-W1_07_5;                            *** [80:85);
         array  WrkH1_8    (I5)  W1_08_1-W1_08_5;                            *** [85:90);

         array  Wrk_H1     (II) WrkH1_1-WrkH1_8 ;               *** h1   for this record;


         array  WrkH2_1    (I5)  W2_01_1-W2_01_5;                            *** [50:55);
         array  WrkH2_2    (I5)  W2_02_1-W2_02_5;                            *** [55:60);
         array  WrkH2_3    (I5)  W2_03_1-W2_03_5;                            *** [60:65);
         array  WrkH2_4    (I5)  W2_04_1-W2_04_5;                            *** [65:70);
         array  WrkH2_5    (I5)  W2_05_1-W2_05_5;                            *** [70:75);
         array  WrkH2_6    (I5)  W2_06_1-W2_06_5;                            *** [75:80);
         array  WrkH2_7    (I5)  W2_07_1-W2_07_5;                            *** [80:85);
         array  WrkH2_8    (I5)  W2_08_1-W2_08_5;                            *** [85:90);

         array  Wrk_H2     (II)  WrkH2_1-WrkH2_8 ;              *** h2   for this record;


         array  Wrk_Beta   (JJ)  Beta1-Beta4;                   *** beta for this record;


         do II = 1 to 8;
            tmp1 = White_H1;                      *** OvCa incidence for the 5yr age cat;
            tmp2 = White_H2;                      *** competing hazs for the 5yr age cat;

            do I5 = 1 to 5;     *** fill in each yr of the 5yr cat with the correct rate;
               Wrk_H1 = tmp1;
               Wrk_H2 = tmp2;
            end;
         end;


         if      (&Race eq 1) then do;
            do II = 1 to 8;
               tmp1 = White_H1;                        *** Dec 6 2012 h1* from R Pfeiffer;
               tmp2 = White_H2;                        *** Dec 6 2012 h2  from R Pfeiffer;

               do I5 = 1 to 5;   *** fill in each yr of the 5yr cat with the correct rate;
                  Wrk_H1 = tmp1;
                  Wrk_H2 = tmp2;
               end;
            end;
         end;

         else if (&Race eq 2) then do;
            do II = 1 to 8;
               tmp1 = Black_H1;                   *** (rateBLACKovariancancer 100113.xls);
               tmp2 = Black_H2;                   *** (rateBLACKovariancancer 100113.xls);

               do I5 = 1 to 5;   *** fill in each yr of the 5yr cat with the correct rate;
                  Wrk_H1 = tmp1;
                  Wrk_H2 = tmp2;
               end;
            end;
         end;


         do JJ = 1 to 4;                                                        *** ln RR;
            Wrk_Beta = White_Beta;
         end;
   run;




   *** document all constants;

   data  Dummy;
   set   TmpFile;

         file print;

         array  White_H1  (II)  WH1_1-WH1_8;       ***  white h1star  OvCa composite incidences;
         array  White_H2  (II)  WH2_1-WH2_8;       ***  black h2,     Competing hazards;

         array  Black_H1  (II)  BH1_1-BH1_8;       *** black  h1star  EnCa composite incidences;
         array  Black_H2  (II)  BH2_1-BH2_8;       *** black  h2,     Competing hazards;

         array  Ages     (II)  A1-A8;
         array  AgesP5   (II)  AP1-AP8;

         do II = 1 to 8;
           AgesP5 = Ages + 5;
         end;


         array  White_Beta (JJ)  I_OC_Beta
                                 I_Parity_Beta
                                 Horm_Beta
                                 FH_Beta;

         array  Beta_Name (JJ) $ CBeta1-CBeta4;


         if (_N_ eq 1) then do;
            put  " ";
            put  "Ln Relative Risk from Cox regressions:   All races use lnRR developed for White AARP/PLCO women  RR model 2";
            put  " ";
            put  "                              African                  Other, Unk    AsianAmrcn";
            put  "Beta              White      American      Hispanic    NativAmrcn    Pacf Islnd";
            put  " ";

            do JJ = 1 to 4;
               put  Beta_Name  $char9.
                    White_Beta   14.7
                    White_Beta   14.7
                    "   Preparation"
                    "   Preparation"
                    "   Preparation";
            end;



            put  " ";
            put  " ";
            put  "1-Attributable Risk:   All races use 1-AR developed for White AARP/PLCO women   RR model 2   F(t)";
            put  " ";
            put  "                              African                  Other, Unk    AsianAmrcn";
            put  "                  White      American      Hispanic    NativAmrcn    Pacf Islnd";
            put  " ";
            put  "1-AR     "
                  White_1_AR   14.7
                  White_1_AR   14.7
                  "   Preparation"
                  "   Preparation"
                  "   Preparation";



            put  " ";
            put  " ";
            put  "Endometrial Cancer Composite Incidences  (H1*)";
            put  " ";
            put  "5 year                        African                  Other, Unk    AsianAmrcn";
            put  "AgeGrp            White      American      Hispanic    NativAmrcn    Pacf Islnd";
            PUT  "             (12/6/2012)  (10/01/2013)                                         ";
            put  " ";

            do II = 1 to 8;
               put "[" Ages 2.0 ":"  AgesP5 2.0 ")"
                   White_H1   16.7
                   Black_H1   14.7
                   "   Preparation"
                   "   Preparation"
                   "   Preparation";
            end;



            put  " ";
            put  " ";
            put  "Competing Mortality  (H2)";
            put  " ";
            put  "5 year                        African                  Other, Unk    AsianAmrcn";
            put  "AgeGrp            White      American      Hispanic    NativAmrcn    Pacf Islnd";
            PUT  "             (12/6/2012)  (10/01/2013)                                         ";
            put  " ";

            do II = 1 to 8;
               put "[" Ages 2.0 ":"  AgesP5 2.0 ")"
                   White_H2   16.7
                   Black_H2   14.7
                   "   Preparation"
                   "   Preparation"
                   "   Preparation";
            end;
         end;

   title5  "Listing of All constants required for OvCa absolute risk projections";
   run;



   *** OvCa risk projection;

   data  TmpFile;
   set   TmpFile;

         array  h1 (j_intvl) W1_01_1-W1_01_5  W1_02_1-W1_02_5  W1_03_1-W1_03_5
                             W1_04_1-W1_04_5  W1_05_1-W1_05_5  W1_06_1-W1_06_5
                             W1_07_1-W1_07_5  W1_08_1-W1_08_5;

         array  h2 (j_intvl) W2_01_1-W2_01_5  W2_02_1-W2_02_5  W2_03_1-W2_03_5
                             W2_04_1-W2_04_5  W2_05_1-W2_05_5  W2_06_1-W2_06_5
                             W2_07_1-W2_07_5  W2_08_1-W2_08_5;

         array  One_AR_RR (j_intvl)  One_AR_RR_01-One_AR_RR_40;

         array  PI_j(j_intvl) Pi1-Pi40;


          ***  tmp sas
               var names
               created in
               this macro
               VVVVV     VVVVVVVV;

         LP2 = I_OC    * I_OC_Beta      +
               Horm    * Horm_Beta      +
               I_Par   * I_Parity_Beta  +
               FamHist * FH_Beta;


         *** double iterated integral ala  eq 2.3  Benichou & Gail Biometrics 46,813-826;

         Strt_Intvl = floor(&T1) - 50 + 1;     *** example:  T1=51 T2=53, Strt_Intvl=51-50+1= 2;
         Endd_Intvl =  ceil(&T2) - 50 + 0;     ***                        EndD_Intvl=53-50+0= 3;
         NumbrIntvl =  ceil(&T2) - floor(&T1); ***                        NumbrIntvl=53-51  = 2;

         RR_Star2   = exp(LP2);               *** RRstar woman of interest at ages ge 50;

         One_AR_RR2 = White_1_AR*RR_Star2;    ***(1-AR)*rr=(1-AR)*exp(xstar*) age ge 50;

         do j_intvl = 1 to 40;
            One_AR_RR = One_AR_RR2;
         end;

         if      (Error_Ind eq 1) then
           &AbsRsk = .;                                      *** erroneous input record
                                                                 set abs risk to missing;

         else if (Error_Ind eq 0) then do;                   *** error free input record;
           &AbsRsk = 0;                                      *** calculate abs risk from;
            Cum_H  = 0;

            do jj = 1 to NumbrIntvl;
               j_intvl = Strt_Intvl + (jj - 1);

               if      (NumbrIntvl gt 1 and jj gt          1
                                       and jj lt NumbrIntvl) then IntgrlLngth = 1;
               else if (NumbrIntvl gt 1 and jj eq          1) then IntgrlLngth = 1 - (&T1 - floor(&T1));
               else if (NumbrIntvl gt 1 and jj eq NumbrIntvl) then IntgrlLngth =     (&T2 - floor(&T2))*(&T2 gt floor(&T2)) +
                                                                                                        (&T2 eq floor(&T2));
               else if (NumbrIntvl eq 1                     ) then IntgrlLngth =      &T2 - &T1;

               Hj = h1*ONE_AR_RR + h2;

               PI_j   = ((One_AR_RR*h1/Hj)*exp(-Cum_H)) * (1-exp(-Hj*IntgrlLngth));
              &AbsRsk = &AbsRsk + PI_j;
               Cum_H  = Cum_H  + Hj*IntgrlLngth;
            end;
         end;


         &AbsRsk = 100*&AbsRsk;


         Key = 1;


         label White_1_AR    =  "1-Attributable risk OvCa Model 2"
               RR_Star2      =  "Relative risk OvCa Model 2"
               One_AR_RR2    =  "(1-AR)*RelRsk OvCa Model 2"
              &AbsRsk        =  "Abs risk (%) of OvCa in age interval [T1,T2) - Model 3";

           *** PattrnNumber  =  "Relative risk covariate pattern #";
   run;


   proc  means  data=TmpFile  mean std n nmiss  maxdec=5;
   var   Error_Ind
        &AbsRsk
         White_1_AR;

   title5  "Quick check for errornous records on input file";
   title6  " ";
   title7  "IF MEAN OF  'Error_Ind'   EQUALS  0,   ERROR  FREE.    ERROR LISTING BELOW "
           "WILL BE EMPTY.";
   title8  "IF MEAN OF  'Error_Ind'   IS NOT  0,   ERRORS EXISTS.  CHECK ERROR LISTING "
           "BELOW.";
   title9  " ";
   title10 "(# of records with errors is the # listed under the NMiss column in the"
           " 'AbsRsk' line)";


   ***   proc contents data=TmpFile  VARNUM position;
   ***   run;


   ***   Error listing file when errors detected as well as writing out a sas file which
         contains the projectd absolute risk as well as all the original input variables
         entryage -- Error_Ind ;

   data &SAS_File   (drop = set_T1_Missing  set_T2_Missing
                            II -- NumbrIntvl
                            Cum_H -- Key  Count_Error);
   set   TmpFile;
   by    Key;


         retain  Count_Error 0;

         file print;

         title5  "Error listing for the input file  (listing up to a max of 1000 records with errors)";


         if (Error_Ind eq 1 and Count_Error le 1000) then do;

            Count_Error = Count_Error + 1;

            if (Count_Error eq 1) then do;

               put "                                                                     " /
                   "                                                               Family" /
                   "                                     Oral            Duratn    Histry" /
                   "                                  Contrac  Parity       HRT      BrCa" /
                   "                                      Use  0= >=3   0=   0y    OvarCa" /
                   "          Currnt  Projct           0=  >1  1= 1:2   1= <10y    0=  no" /
                   "    ID #     Age     Age    Race   1= 0,1  2=   0   2=  10y+   1= yes" /
                   "                                                             " ;
            end;

            Put

            &Woman_ID                        8.0
            &T1                              8.1
            &T2                              8.1

            &Race                            8.0

            &Invrs_OC_Model                  9.0
            &Invrs_Parity_Model              8.0
            &Horm_Model                     10.0
            &FHbreast_Model                 10.0;

            Put

            set_T1_Missing                  16.1
            set_T2_Missing                   8.1

            RacCat                           8.0

            I_OC                             9.0
            I_Par                            8.0
            Horm                            10.0
            FamHist                         10.0;

            Put;
         end;


         Label  Count_Error = "Counts # of edit errors in input file ";

         if (last.Key and Count_Error eq 0) then do;
            put " ";
            put "      -------------------------------------------"
                "----------------------------";
            put " ";
            put "      No errors detected for entry age, exit age "
                "and relative risk covaraites";
            put " ";
            put "      -------------------------------------------"
                "----------------------------";
         end;
         else if (last.Key and Count_Error gt 0) then do;
            put " ";
            put "There are " Count_Error 6.0 " records with errors in covariate values on input file";
            put " ";
            put " ";
         end;

   run;


   data &SAS_File;
   set  &SAS_File;
   run;
%mend;
