Saturday, July 25, 2015

Tooth About Tobacco

/*
  Data and SAS code to accompany the article
  "The Tooth about Tobacco", published 25Jul2015,
  http://kansascode.blogspot.com/2015/07/the-tooth-about-tobacco_25.html  

  Inspired by Rick Wicklin's blog post
  "The relationship between toothlessness and income in seniors", published 24Jul2015,
  http://blogs.sas.com/content/iml/2015/07/24/income-vs-toothless.html

  Inspired by Robert Allison's blog post
  "Only brush the teeth you want to keep", published 23Jul2015,
  http://blogs.sas.com/content/sastraining/2015/07/23/only-brush-the-teeth-you-want-to-keep/
*/

data cigs ;
  input 
    state & $20.
    cigaretteusage : percent8.1 ;
    format cigaretteusage percent8.1 ;
    label cigaretteusage = 'Cigarette Usage' ;
 datalines ;
Alabama  24.3%
Alaska   22.9%  
Arizona  19.2%
Arkansas   27.0%
California  13.7%
Colorado  18.3%
Connecticut  17.1%
Delaware  21.7%
District of Columbia  20.8%
Florida  19.3%
Georgia  21.2%
Hawaii  16.8%
Idaho  17.2%
Illinois  20.9%
Indiana  25.6%
Iowa  20.4%
Kansas  22.0%
Kentucky  29.0%
Louisiana  25.7%
Maine  22.8%
Maryland  19.1%
Massachusetts  18.2%
Michigan  23.3%
Minnesota  19.1%
Mississippi  26.0%
Missouri  25.0%
Montana  22.1%
Nebraska  20.0%
Nevada  22.9%
New Hampshire  19.4%
New Jersey  16.8%
New Mexico  21.5%
New York  18.1%
North Carolina  21.8%
North Dakota  21.9%
Ohio  25.1%
Oklahoma  26.1%
Oregon  19.7%
Pennsylvania  22.4% 
Rhode Island  20.0%
South Carolina  23.0%
South Dakota  19.2%
Tennessee  23.0%
Texas  19.2%
Utah  11.8%
Vermont  19.1%
Virginia  20.9%
Washington  17.5%
West Virginia  28.6%
Wisconsin  20.9%
Wyoming  23.0%
;
run ;

data bmi ;
  infile datalines truncover ;
  input 
    state & $20.
    BMI
    bmilcl
    bmiucl ;
  datalines ;
Alabama  32.4 30.8 34.1
Alaska  28.4 26.5 30.4 
Arizona  26.8 24.3 29.4 
Arkansas  34.6 32.7 36.6 
California  24.1 23.0 25.3 
Colorado  21.3 20.4 22.2 
Connecticut  25.0 23.5 26.4 
Delaware  31.1 29.3 32.8 
District of Columbia  22.9 21.0 24.8 
Florida  26.4 25.3 27.4
Georgia  30.3 28.9 31.8
Guam  27.0 24.4 29.8
Hawaii  21.8 20.4 23.2
Idaho  29.6 27.8 31.4
Illinois  29.4 27.7 31.2 
Indiana  31.8 30.6 33.1 
Iowa  31.3 29.9 32.7 
Kansas  30.0 29.2 30.7 
Kentucky  33.2 31.8 34.6 
Louisiana  33.1 31.1 35.2 
Maine  28.9 27.5 30.2 
Maryland  28.3 27.0 29.5 
Massachusetts  23.6 22.5 24.8 
Michigan  31.5 30.4 32.6
Minnesota  25.5 24.1 26.8 
Mississippi  35.1 33.5 36.8 
Missouri  30.4 28.8 32.1 
Montana  24.6 23.4 25.8 
Nebraska  29.6 28.4 30.7 
Nevada  26.2 24.0 28.6 
New Hampshire  26.7 25.3 28.3 
New Jersey  26.3 25.1 27.5 
New Mexico  26.4 25.1 27.7 
New York  25.4 24.2 26.6 
North Carolina  29.4 28.1 30.7 
North Dakota  31.0 29.5 32.5 
Ohio  30.4 29.2 31.6 
Oklahoma  32.5 31.2 33.9 
Oregon  26.5 24.9 28.1 
Pennsylvania  30.0 28.9 31.2 
Puerto Rico  27.9 26.4 29.5 
Rhode Island  27.3 25.8 28.8 
South Carolina  31.7 30.5 33.1 
South Dakota  29.9 28.0 31.8 
Tennessee  33.7 31.9 35.5 
Texas  30.9 29.5 32.3 
Utah  24.1 23.2 25.1 
Vermont  24.7 23.4 26.1 
Virginia  27.2 25.9 28.5 
Washington  27.2 26.0 28.3 
West Virginia  35.1 33.6 36.6 
Wisconsin  29.8 28.0 31.6 
Wyoming  27.8 26.2 29.5 
;
run ;

data Teeth;
input State $20. pct LCL UCL StdErr N;
informat  pct PERCENT8.1
          LCL PERCENT8.1
          UCL PERCENT8.1
          StdErr PERCENT8.1
          N COMMA5.;    
format pct PERCENT6.;
label pct = "Percent of Seniors";
datalines;
Alabama              27.2% 23.8% 30.6% 1.7%   813 
Alaska               23.6% 16.9% 30.3% 3.4%   262 
Arizona              14.3% 11.5% 17.1% 1.4% 1,400 
Arkansas             22.7% 20.4% 25.0% 1.2% 1,558 
California           14.0% 10.9% 17.1% 1.6% 1,316 
Colorado             12.9% 10.9% 14.9% 1.0% 1,238 
Connecticut          12.8% 11.1% 14.5% 0.8% 2,191 
Delaware             17.8% 14.9% 20.7% 1.5%   992 
District of Columbia 20.8% 16.9% 24.7% 2.0%   789 
Florida              17.4% 15.7% 19.1% 0.9% 3,109 
Georgia              21.5% 19.0% 24.0% 1.3% 1,721 
Hawaii               9.6%   7.6% 11.6% 1.0% 1,433 
Idaho                19.7% 17.1% 22.3% 1.3% 1,217 
Illinois             19.3% 16.6% 22.0% 1.4% 1,270 
Indiana              21.2% 18.9% 23.5% 1.2% 1,551 
Iowa                 19.8% 17.6% 22.0% 1.1% 1,476 
Kansas               19.1% 17.3% 20.9% 0.9% 2,161 
Kentucky             38.9% 35.9% 41.9% 1.6% 1,628 
Louisiana            28.9% 26.3% 31.5% 1.3% 1,473 
Maine                26.2% 22.9% 29.5% 1.7%   912 
Maryland             16.2% 14.0% 18.4% 1.1% 2,131 
Massachusetts        17.2% 15.5% 18.9% 0.9% 3,012 
Michigan             17.3% 15.1% 19.5% 1.1% 1,394 
Minnesota            18.6% 16.1% 21.1% 1.3% 1,051 
Mississippi          31.5% 28.9% 34.1% 1.3% 1,643 
Missouri             24.1% 21.0% 27.2% 1.6% 1,513 
Montana              18.2% 15.9% 20.5% 1.2% 1,474 
Nebraska             18.6% 16.7% 20.5% 1.0% 2,234 
Nevada               18.4% 14.6% 22.2% 1.9%   802 
New Hampshire        18.6% 16.3% 20.9% 1.2% 1,347 
New Jersey           18.2% 16.6% 19.8% 0.8% 3,666 
New Mexico           23.8% 21.3% 26.3% 1.3% 1,588 
New York             17.5% 15.3% 19.7% 1.1% 1,521 
North Carolina       22.6% 21.0% 24.2% 0.8% 4,045 
North Dakota         22.9% 20.1% 25.7% 1.4% 1,327 
Ohio                 21.6% 17.8% 25.4% 1.9% 1,560 
Oklahoma             28.3% 26.1% 30.5% 1.1% 2,091 
Oregon               15.9% 13.7% 18.1% 1.1% 1,233 
Pennsylvania         23.9% 21.5% 26.3% 1.2% 3,547 
Rhode Island         17.9% 15.6% 20.2% 1.2% 1,211 
South Carolina       23.0% 20.8% 25.2% 1.1% 2,354 
South Dakota         21.4% 19.3% 23.5% 1.1% 1,909 
Tennessee            34.9% 31.1% 38.7% 1.9% 1,094 
Texas                18.6% 15.8% 21.4% 1.4% 1,689 
Utah                 14.8% 12.3% 17.3% 1.3% 1,014 
Vermont              19.7% 17.7% 21.7% 1.0% 1,742 
Virginia             14.4% 12.0% 16.8% 1.2% 1,223 
Washington           15.4% 14.3% 16.5% 0.6% 6,337 
West Virginia        40.5% 37.2% 43.8% 1.7% 1,005 
Wisconsin            16.9% 14.4% 19.4% 1.3% 1,055 
Wyoming              20.1% 17.6% 22.6% 1.3% 1,165 
;
run ;

data teethbmi ;
  merge teeth bmi ;
  by state ;
run ;

data teethcig ;
  merge teeth cigs ;
  by state ;
run ;

proc corr data = teethbmi noprint outp = opbmi( where = ( _type_ = 'CORR' and _name_ = 'BMI' ) )  ;
  var bmi pct ;
run ;

data _null_ ;
  set opbmi ;
  call symputx( 'BMICORR', put( pct, 8.5 ) ) ;
run ;

title "All Teeth Extracted vs. BMI";
footnote j = l "Source: http://www.cdc.gov/obesity/data/table-adults.html" ;
proc sgplot data = teethbmi ;
  scatter x = bmi y = pct / datalabel = state ;
  loess   x = bmi y = pct ;
  refline 18.5 / axis = x label = "Normal (18.5 - 24.99)"   lineattrs = ( color = red ) ;
  refline 25   / axis = x label = "Overweight (25 - 29.99)" lineattrs = ( color = red ) ;
  refline 30   / axis = x label = "Obese (over 30)"         lineattrs = ( color = red ) ;
  xaxis values = ( 17.5 to 37.5 by 2.5 ) ;
  inset "Correlation Coefficient = &bmicorr" / 
    border 
    title = "Pearson" 
    position = bottomright ;
run ;

proc corr data = teethcig noprint outp = opcig( where = ( _type_ = 'CORR' and _name_ = 'cigaretteusage' ) )  ;
  var cigaretteusage pct ;
run ;

data _null_ ;
  set opcig ;
  call symputx( 'CIGCORR', put( pct, 8.5 ) ) ;
run ;

title "All Teeth Extracted vs. Cigarette Usage" ;
footnote j = l "Source: http://www.cdc.gov/tobacco" ;
proc sgplot data = teethcig ;
  scatter x = cigaretteusage y = pct / datalabel = state ;
  loess   x = cigaretteusage y = pct ;
  refline .212 / axis = x label = "Avg (21.2%)" lineattrs = ( color = red ) ;
  inset "Correlation Coefficient = &cigcorr" / 
    border 
    title = "Pearson" 
    position = bottomright ;
run ;

title ;
footnote ;

No comments:

Post a Comment