Skip directly to search Skip directly to A to Z list Skip directly to navigation Skip directly to site content Skip directly to page options
CDC Home

SAS, SPSS, and SUDAAN syntax

Below are SAS, SPSS, and SUDAAN syntax to appropriately recode and/or create the following Healthy Days variables:

  • Self-rated health (including the derived measure of the percent of persons with fair to poor self-rated health)
  • Physically unhealthy days
  • Mentally unhealthy days
  • Unhealthy days (sum of physically and mentally unhealthy days not to exceed 30 days)
  • Activity limitation days



SAS syntax

Self-rated health
(including the derived measure of percent fair->poor self-rated health);

if (genhlth in(1,2,3,4,5)) then do;
if (genhlth in(4,5))
then fairpoor=100;
else fairpoor=0;
end;
else genhlth=.;
label fairpoor="Percent fair->poor self-rated health";

Physically and mentally unhealthy days and recent activity limitation days;

* Convert values of 88 to zero and out-of-range values to missing.;
* If the number of physical health days not good equals zero, and;
* if the number of mental health days not good equals zero, and;
* if the number of recent activity limitation days is missing (skip pattern),;
* then change (impute) the number of recent activity limitation days to zero days.;

array qoldays physhlth menthlth poorhlth;
do over qoldays;
select;
when (qoldays eq 88) qoldays=0;
when ((qoldays lt 0) or
(qoldays gt 30)) qoldays=.;
otherwise;
end;
end;
if ((physhlth eq 0) and
(menthlth eq 0) and
(poorhlth eq .)) then poorhlth=0;

* Derived measure: Unhealthy days;

if ((physhlth ne .) and
(menthlth ne .))
then unhealth=min(30,sum(physhlth,menthlth));
else unhealth=.;
label unhealth="# Unhealthy days in past 30 days";

* Derived measure: Percent with frequent mental distress;

select;
when (14 <= menthlth <= 30) frqmentd=100;
when ( 0 <= menthlth <= 13) frqmentd=0;
otherwise frqmentd=.;
end;
label frqmentd="Percent with frequent mental distress";

Top of Page

SPSS syntax

**Computed measure: Percent fair to poor health**
Use self-rated health variable (GENHLTH); recode into 2 categories: (1) excellent, very good, good; (2) fair, poor*

RECODE
GENHLTH
(MISSING=SYSMIS)(1 thru 3=0) (4 thru 5=100) (ELSE=SYSMIS) INTO FAIRPOOR .
VARIABLE LABELS FAIRPOOR 'percent fair poor'.
EXECUTE .

**Physically and mentally unhealthy days, and recent activity limitation days** **(recoding to account for zero days (coded as 88 in BRFSS), missing values, data entry errors/outliers)**

RECODE
PHYSHLTH
(88=0) (77=SYSMIS) (99=SYSMIS) (LOWEST THRU -1=SYSMIS)
(31 THRU HIGHEST=SYSMIS)(ELSE=Copy) INTO PHYSR .
VARIABLE LABELS PHYSR 'physically unhealthy days'.
EXECUTE .

RECODE
MENTHLTH
(88=0) (77=SYSMIS) (99=SYSMIS) (LOWEST THRU -1=SYSMIS)
(31 THRU HIGHEST=SYSMIS)(ELSE=Copy) INTO MENTR.
VARIABLE LABELS MENTR 'mentally unhealthy days'.
EXECUTE .

**Activity limitation days**

**Note: If physically unhealthy days is zero (0) and mentally unhealthy days is zero (0), the question on activity limitation days (due to poor physical or mental health) is skipped. We impute a zero (0) for this value. Please note original coding for the missing (skipped) value, since it might be coded as a MISSING, SYSMIS, or sometimes as a ".00" value. Imputing zero days is only valid when mentally unhealthy days and physically unhealthy days are both zero.**

**The example below assumes SYSMIS displays skipped cases; 88 displays persons asked the question, but who responded zero days; 77 displays persons who were asked the question but were unsure; and 99 displays persons who were asked the question but refused to answer it.**

RECODE
POORHLTH
(88=0) (77=SYSMIS)(99=SYSMIS)(SYSMIS=0)(ELSE=Copy) INTO PORHLTHR .
VARIABLE LABELS PORHLTHR 'activity limitation days'.
EXECUTE .

**Computed measure: Unhealthy days**

**(If either value of physically unhealthy days or mentally unhealthy days is missing, this computes the resulting appropriate missing value.)**

COMPUTE SUMDAYS=PHYSR+MENTR.
VARIABLE LABELS SUMDAYS 'sum of phys ment days'.
EXECUTE.

**recoding maximum value of SUMDAYS to 30, since 30 days is the logical maximum value of overall unhealthy days; see page 9 of the technical monograph, Measuring Healthy Days (CDC 2000), for additional information on overlap**

RECODE
SUMDAYS
(SYSMIS=SYSMIS) (0 thru 30=Copy) (31 thru Highest=30) INTO UNHLTH.
VARIABLE LABELS UNHLTH 'sum of phys ment days recoded so max <31'.
EXECUTE.

**Computed measure: Percent with frequent mental distress**

RECODE
MENTR
(0 thru 13=0) (14 thru Highest=100) (ELSE=SYSMIS) INTO MENTDIST.
VARIABLE LABELS MENTDIST 'frequent mental distress'.
EXECUTE .

Top of Page

SUDAAN syntax

(using SPSS data sets as well as SAS data sets: Check your version of SUDAAN for the version of SAS data set it can read**)

*Note for SAS and SPSS users:

  1. *To let SUDAAN read SPSS files, simply replace FILETYPE=SAS with FILETYPE=SPSS.

  2. *You must apply the final weight (FINALWT) to your SPSS analyses when exploring your data in SPSS in order to obtain similar (i.e., accurate) point estimates generated by SUDAAN.

  3. *Use of SUDAAN versions prior to 7.5.6 and SPSS might generate the following WARNING message: "File warning: Don't know how to interpret subtype 11 records. Skipping this information. SUDAAN may or may not be able to read this file." We have confirmed with support staff from SPSS,Inc. RTI, and with our own analyses that this message is innocuous and unrelated to any bugs reading SPSS data. Use of SUDAAN 7.5.6 or 8.0 should correct this error message.

  4. *Do not use SAS transport files (.xpt extension) or SPSS portable files (.por extension).

  5. *Be sure to use SAS and SPSS version data sets compatible with SUDAAN version used.

To account for the complex sample survey design in BRFSS (=WR=sampling with replacement), use the following design and weight variables from, for example, the 2000 BRFSS data set:

_STSTR = the sampling stratum
_PSU = the primary sampling unit
_FINALWT = the weight of each observation.

and sort the SAS or SPSS data set by the design variables, _STSTR and _PSU, in the SUDAAN NEST statement, in preparation for analysis with SUDAAN.

SUDAAN examples:

  1. If you were interested in the mean number of physically unhealthy days (PHYSHLTH), mentally unhealthy days (MENTHLTH), unhealthy days (UNHLTH), and activity limitation days (POORHLTH), use the following SUDAAN code:

    [VARIABLE NAMES: PHYSHLTH, MENTHLTH, UNHLTH, POORHLTH]

    PROC DESCRIPT DATA=(your data filename) FILETYPE=SAS DESIGN=WR;
    NEST _STSTR _PSU / MISSUNIT;
    WEIGHT _finalwt;
    VAR PHYSHLTH MENTHLTH UNHLTH POORHLTH;

  2. If you were interested in the percentage of persons with fair to poor health (FAIRPOOR), use the following SUDAAN code:

    PROC CROSSTAB DATA=(your data filename) FILETYPE=SAS DESIGN=WR;
    NEST _STSTR _PSU / MISSUNIT;
    WEIGHT _finalwt;
    SUBGROUP FAIRPOOR;
    LEVELS 2;

  3. If you were interested in the mean number of unhealthy days by sex, income, and age group, you would use the following SUDAAN code:

    [VARIABLE NAMES: SEX, INCOME3, AGEGRP2, UNHLTH, FINALWT]

    PROC DESCRIPT DATA=(your data filename) FILETYPE=SAS DESIGN=WR;
    NEST _STSTR _PSU / MISSUNIT;
    WEIGHT _FINALWT;
    SUBGROUP AGEGRP2 SEX INCOME3;
    LEVELS 3 2 5;
    VAR UNHLTH;
    TABLES SEX*INCOME3*AGEGRP2;

Top of Page

Back to Methods and Measures

 
Contact Us:
  • Centers for Disease Control and Prevention
    Health Related
    Quality of Life
    Surveillance Program
    1600 Clifton Rd
    Atlanta, GA 30333
  • 800-CDC-INFO
    (800-232-4636)
    TTY: (888) 232-6348
    8am-8pm
    ET/Monday-Friday
    Closed Holidays
  • Contact CDC-INFO
USA.gov: The U.S. Government's Official Web PortalDepartment of Health and Human Services
Centers for Disease Control and Prevention   1600 Clifton Rd. Atlanta, GA 30329-4027, USA
800-CDC-INFO (800-232-4636) TTY: (888) 232-6348 - Contact CDC-INFO