Tutorial Formats

/*formats used for NHANES web tutorial*/

proc format ;

      value agefmt  

                  1 = 'Age 20-39'

                  2 = 'Age 40-59'

                  3 = 'Age 60+' ;

      value age1fmt    

                  1 = '20-29 years'

                  2 = '30-39 years'

                   3 = '40-49 years'

                   4 = '50-59 years'

                  5 = '60-69 years'

                  6 = '70 years and older' ;

      value bmifmt

                   1 = 'BMI <25'

                  2 = '25<= BMI <30'

                  3 = 'BMI >=30' ;

value bpfmt

                  1 = 'hypertension'

                  0 = 'no hypertension' ;

      value chfmt

                  1 = 'high cholesterol'

                  0 = 'not high cholesterol' ;                      

      value csz1fmt /*1 st blood pressure cuff size recode(SUDAAN)*/

                  1 = 'Infant/Child'

                  2 = 'Adult'

                  3 = 'Large'

                  4 = 'Thigh' ;

      value csz2fmt /*2 nd blood pressure cuff size recode (SAS)*/

                  1 , 2 = 'Infant/Child'

                  3 = 'Adult'

                  4 = 'Large'

            5 = 'Thigh' ;

      value educ

                  1 = "< HS"

                  2 = "HS/GED"

                  3 = "> HS" ;

      value hbpfmt

                  1 = 'high BP'

                  2 = 'low BP' ;    

      value hbp2fmt

                100 = 'high BP'

            0 = 'No high BP' ;

      value race  1 = 'Mexican American'
                  2 = 'Other Hispanic'
                  3 = 'Non-Hispanic White'
                  4 = 'Non-Hispanic Black'
                  5 = 'Other Race - Including Multi-Racial' ;

      value racefmt 

                  1 = 'NH White'

                  2 = 'NH Black'

                  3 = 'Mexican American'

                  4 = 'Other race/ethn' ;

 

      value rac2fmt

                  1 = 'Mexican American'

                  3 ='Non-Hispanic White'
                  4 = 'Non-Hispanic Black' ;

      value race3fmt

                  1 = 'Mexican American'

                  2 = 'Non-Hispanic black'

                  5 = 'Non-Hispanic white' ;

      value selfmt

                  1 = 'Age ge 20'

                   2 = 'Age lt 20' ;        
       value sexfmt

                   1 = 'Male'

                   2 = 'Female' ;

      value sex2fmt

                  1 = 'Female'

                   2 = 'Male';

      value smkfmt

                  1 = 'Never smoker'

                  2 = 'Past smoker'

                  3 = 'Current smoker' ;                           

      value yesno

                  1 = 'Yes'

                  2 = 'No' ;

 

format age3cat age  agefmt.

       age1         age1fmt.

       bmigrp       bmifmt.

       hyper        bpfmt.

       HLP Hicol    chfmt.

 bpacsz        csz1fmt. (SUDAAN recode for bpacsz)

 bpacsz        csz2fmt.

 dmdeduc      educ.

        HBP           hbpfmt.

  hbpx        hbp2fmt .

       ridreth1     race.

       raceth race  racefmt.

       ridreth1     race2fmt.

       ethn         race3fmt.

       sel          selfmt.

       riagendr     sexfmt.

       sex          sex2fmt. (linear regression)           

       smoker       smkfmt.               

       SBP140 DBP90 HBP_trt HBP HLP_lab HLP_trt HLP yesno.

  ;

 

AGE:

     

      /*Create age categorical variable*/

       if       ( 20 <= ridageyr <= 39 ) then age3cat= 1;

       else if ( 40 <= ridageyr <= 59 ) then age3cat= 2;

       else if         ridageyr >= 60   then age3cat

 

        age = . ;

       if 20 LE ridageyr LE 39 then age= 1;

       if 40 LE ridageyr LE 59 then age= 2;  

       if        ridageyr GE 60 then age= 3

 

      age1 = . ;

      if 20 LE ridageyr LE 29 then age1= 1;

      if 30 LE ridageyr LE 39 then age1= 2;

      if 40 LE ridageyr LE 49 then age1= 3;

      if 50 LE ridageyr LE 59 then age1= 4;

      if 60 LE ridageyr LE 69 then age1= 5;

      if        ridageyr GE 70 then age1= 6;  

 

      /*define variable for subpopulation ge 20 and le 20*/

      if ridageyr ge 20 then sel=1;

      else sel=2;

 

BLOOD PRESSURE:

 

*Create an indicator of hypertension based on average blood pressure variables on datafile (systolic blood pressure-bpxsar); (diastolic blood pressure-bpxdar); and medication;

     

if (bpxsar >= 140 or bpxdar >= 90 or bpq050a = 1) then Hyper = 1;

      else if (bpxsar ne . and bpxdar ne .) then Hyper = 0;

 

 

/*Count Number of Non-missing Systolic Blood Pressure(SBP) &    Diastolic Blood Pressure(DBP)*/

      n_sbp = n(of bpxsy1-bpxsy4);

      n_dbp = n(of bpxdi1-bpxdi4);

      *Set DBP values of 0 as missing for calculating average;

      array _DBP bpxdi1-bpxdi4;

      do over _DBP;

      if (_DBP = 0 ) then _DBP = . ;

      end

      *Calculate mean SBP and DBP;

      mean_sbp = mean(of bpxsy1-bpxsy4);

      mean_dbp = mean(of bpxdi1-bpxdi4);

      /*Define hypertension based on questionnaire and exam data*/

      if BPQ050a= 1 then HBP_trt= 1;

      else if BPQ020 in ( 1,2) and BPQ050a < 7 then HBP_trt= 0;

      if n_sbp> 0 and n_dbp>0 then do ;

            if mean_sbp>= 140 then SBP140= 1;

            else SBP140= 0;

            if mean_dbp>= 90 then DBP90= 1;

            else DBP90= 0;

      end ;

      if HBP_trt>= 0 and SBP140>=0 and DBP90>=0 then do ;

            if HBP_trt= 1 or SBP140=1 or DBP90=1 then HBP= 1;

            else HBP= 0;

      end ;

 

      ********if coded as HBP=1; HBP=2;******************

 

          if HBP_trt>= 0 and SBP140>=0 and DBP90>=0 then do ;

      if HBP_trt= 1 or SBP140=1 or DBP90=1 then HBP= 1;

            else HBP=2;

      end ;

 

/*Define high blood pressure as continuous for some analytic   procedures*/

     hbpx= . ;

     if hbp = 1 then hbpx = 100 ;

     if hbp = 2 then hbpx = 0 ;

 

     

/*The recode statement in SUDAAN merges infant and child blood pressure cuff sizes to create four  levels of cuff size.*/

      recode bpacsz = (1 3 4 5);

      rformat bpacsz csz1fmt.;

    

/* In SAS, a format can be used to merge infant and child blood pressure cuff sizes*/.

 

      table riagendr*bpacsz/col row nostd nowt wchisq wllchisq;

format bpacsz csz2fmt.;

 

BMI:

             

      /*Create bmi groups;*/

      if        0 <= bmxbmi  <25 then bmigrp= 1 ;

      else if 25 <= bmxbmi  <30 then bmigrp= 2 ;

      else if        bmxbmi >=30 then bmigrp= 3 ;

 

CHOLESTEROL:

 

/*Define high cholesterol based on questionnaire and lab data*/

      if BPQ100d= 1 then HLP_trt= 1;

      else if BPQ080 in ( 1,2) and BPQ100d<7 then HLP_trt= 0;

      if lbxtc>= 240 then HLP_lab= 1;

      else if lbxtc>= 0 then HLP_lab= 0;

 

      if HLP_lab>= 0 and HLP_trt>=0 then do ;

            if HLP_lab= 1 or HLP_trt=1 then HLP= 1;

            else HLP= 0;

      end ;

 

 

*create an indicator of high cholesterol based on total cholesterol and medication;

      if (lbxtc>=240 or bpq100d = 1) then HiChol = 1;

      else if (lbxtc ne . ) then HiChol = 0;

 

GENDER:

 

/*for input to SAS PROC SURVEYREG - recode gender so that men is   the reference group (linear regression)*/

      if riagendr eq 1 then sex= 2 ;

      else if riagendr eq 2 then sex= 1 ;

 

Race:

 

/*Regroup race/ethnicity (ridreth1) as 4 categories*/

 

      if ridreth1= 3 then raceth= 1;         /*Non-Hispanic White*/

      else if ridreth1= 4 then raceth= 2;    /*Non-Hispanic Black*/

      else if ridreth1= 1 then raceth= 3;    /*Mexican American*/

      else raceth= 4;                       /*Other*/

 

      race=.;

      if ridreth1= 3 then race= 1;               /*Non-Hispanic White*/

      if ridreth1= 4 then race= 2;               /*Non-Hispanic Black*/

      if ridreth1= 1 then race= 3;               /*Mexican American*/

      if ridreth1= 2 or ridreth1=5 then race= 4; /*Other*/

 

/*for input to SAS PROC SURVEYREG - recode race/ethnicity      so that non-Hispanic white is the reference group*/

      ethn=ridreth1;

      if ridreth1 eq 3 then ethn= 5 ;

      else if ridreth1 eq 4 then ethn= 2 ;

      else if ridreth1 eq 2 then ethn= 3 ;

      else if ridreth1 eq 5 then ethn= 4 ;

 

SMOKING:

 

/*define smokers*/

      if smq020 eq 2 then smoker= 1 ;

      else if smq020 eq 1 and smq040 eq 3 then smoker= 2 ;

      else if smq020 eq 1 and smq040 in( 1 , 2 ) then smoker= 3 ;

 

 

 

 

 

 

 

close window icon Close Window