BookmarkSubscribeRSS Feed
pbstubejunkie
Calcite | Level 5

 

 

proc format ;

invalue $primedrv

'N' = 'No'

'Y' = 'Yes'

' ' = 'Missing'

;

 

value primedrv

1 = 'No'

2 = 'Yes'

3 = 'Missing'

;

 

value healthcdv

1 = 'Excellent'

2 = 'Very Good'

3 = 'Good'

4 = 'Fair'

5 = 'Poor'

6 = 'Uknown'

. = 'Missing'

;

 

invalue healthcdv

  "Excellent" = 1

  "Very Good" = 2

  "Good"    = 3

  "Fair"    = 4

  "Poor"      = 5

  "Unknown"   = 6

  "Missing"   = 7

  ;

 

value $coldv

'N' = 'No'

'Y' = 'Yes'

' ' = 'Missing'

;

 

value $highbpv

'N' = 'No'

'Y' = 'Yes*'

' ' = 'Missing'

;

 

value $bpmedsv

'N' = 'No'

'Y' = 'Yes'

' ' = 'Missing'

;

 

value checkupcdv

1 = 'Less than 1 year'

2 = 'Within 2 years'

3 = 'Within 5 years'

4 = 'More than 5 years'

5 = 'Not sure'

6 = 'Never'

. = 'Missing'

;

 

value smclscdv

1 = 'Current Smoker'

2 = 'Past smoker'

3 = 'Non-smoker'

. = 'Missing'

;

 

 

  

   ;

 

   invalue checkupcdv

  "Less than 1 year" = 1

  "Within 2 years" = 2

  "Within 5 years" = 3

  "More than 5 years" = 4

  "Not sure " = 5

  "Never" = 6

  "Missing" = 7

  ;

 

 

 

   value tcat

1 = "^R'\ql\b 'Days of Wine Consumption in the Past Month"

2 = "^R'\ql\b 'Days of Other Alcohol Consumption in the Past Month"

3 = "^R'\ql\b 'Personal Health Care Provider, n (%)"

4 = "^R'\ql\b 'Overall Health Status, n (%)"

5 = "^R'\ql\b 'Cold or Flu in Past Month, n (%)"

6 = "^R'\ql\b 'Days missed Work:"

7 = "^R'\ql\b 'High Blood Pressure, n (%)"

8 = "^R'\ql\b 'Taking Medication, n (%)"

9 = "^R'\ql\b 'Time since Last Routine Checkup, n (%)"

;

value mstats 

1 = 'n'

                2 = 'mean'

                3 = 'std dev'

                4 = 'min'

                5 = 'max'

                ;

 

invalue mstats 

'N'    = 1

                'MEAN' = 2

                'STD'  = 3

                'MIN'  = 4

                'MAX'  = 5

                 ;

 

run ;

 

proc contents data=table3.adpbhl623 ;

run ;

 

data alldata ;

set table3.adpbhl623  ;

if subjid ne . then total = 1000 ;

if misswork = 99 then misswork = 0 ;

if wine = 99 then wine = 0 ;

if wine = 88 then wine = . ;

if alcohol = 99 then alcohol = 0 ;

if alcohol = 88 then alcohol = . ;

run;

run ;

 

proc freq data=alldata ;

table total ;

 

proc freq data=alldata noprint;

table smclscd   / out=denoms    (drop=percent) ; 

table primedr*smclscd   / out=primecnt  (drop=percent) ;

table healthcd*smclscd  / out=healthcnt (drop=percent) ;

table cold*smclscd     / out=coldcnt (drop=percent) ;

table misswork*smclscd  / out=misscnt (drop=percent) ;

table highbp*smclscd    / out=highcnt (drop=percent) ;

table bpmeds*smclscd    / out=bpcnt (drop=percent) ;

table checkupcd*smclscd / out=checkcnt (drop=percent) ;

*GIVES COUNTS FOR EACH OF THE VARIABLES;

table total / out=totdenoms (drop=percent) ;

table primedr*total / out=primetot  (drop=percent) ;

table healthcd*total / out=healthtot (drop=percent) ;

table cold*total / out=coldtot (drop=percent) ;

table misswork*total / out=misstot (drop=percent) ;

table highbp*total / out=hightot (drop=percent) ;

table bpmeds*total / out=bptot (drop=percent) ;

table checkupcd*total / out=checktot (drop=percent) ;

run;

 

data bptotcnt (where=(highbp = 'Y')) ;

set alldata ;

run ;

 

proc freq data=bptotcnt noprint ;

table smclscd / out=bpden (drop=percent) ;

table total / out=bptotdenoms (drop=percent) ;

table bpmeds*smclscd / out=bpsmdenoms (drop=percent) ;

table bpmeds*total / out=bpmeddenoms (drop=percent) ;

run ;

 

proc print data=denoms ;

title 'TABLE DENOMS' ;

run ;

 

proc print data=totdenoms ;

title 'TABLE DENOMS FOR TOTALS' ;

run ;

 

 

proc transpose data=denoms out=tdenoms prefix=den_ ;

where not missing(smclscd) ;

id smclscd ;

var count ;

run ;

 

proc print data=tdenoms ;

title 'TRANSPOSED DENOMS' ;

run ;

 

proc transpose data=primecnt out=tprimecnt prefix=cnt_ ;

where not missing(smclscd) ;

by primedr ;

id smclscd ;

var count ;

run ;

 

proc print data=tprimecnt ;

title 'TRANSPOSED TPRIMECNT'

run ;

 

proc transpose data=healthcnt out=thealthcnt prefix=cnt_ ;

where not missing(smclscd) ;

by healthcd ;

id smclscd ;

var count ;

run ;

 

proc print data=thealthcnt ;

title 'TRANSPOSED THEALTHCNT'

run ;

 

proc transpose data=coldcnt out=tcoldcnt prefix=cnt_ ;

where not missing(smclscd) ;

by cold ;

id smclscd ;

var count ;

run ;

 

proc print data=tcoldcnt ;

title 'TRANSPOSED TCOLDCNT'

run ;

 

proc transpose data=misscnt out=tmisscnt prefix=cnt_ ;

where not missing(smclscd) ;

by misswork ;

id smclscd ;

var count ;

run ;

 

proc print data=tmisscnt ;

title 'TRANSPOSED TMISSCNT'

run ;

 

proc transpose data=highcnt out=thighcnt prefix=cnt_ ;

where not missing(smclscd) ;

by highbp ;

id smclscd ;

var count ;

run ;

 

proc print data=thighcnt ;

title 'TRANSPOSED TALCNT'

run ;

 

proc transpose data=bpcnt out=tbpcnt prefix=cnt_ ;

where not missing(smclscd) ;

by bpmeds ;

id smclscd ;

var count ;

run ;

 

proc print data=tbpcnt ;

title 'TRANSPOSED TBPCNT'

run ;

 

proc transpose data=checkcnt out=tcheckcnt prefix=cnt_ ;

where not missing(smclscd) ;

by checkupcd ;

id smclscd ;

var count ;

run ;

 

proc print data=tcheckcnt ;

title 'TRANSPOSED TALCNT'

run ;

 

**--TRANSPOSE TOTALS DENOMS--** ;

 

proc transpose data=totdenoms out=ttotdenoms prefix=den_ ;

id total ;

var count ;

run ;

 

proc print data=ttotdenoms ;

title 'TRANSPOSED TTOTDENOMS' ;

run ;

 

proc transpose data=primetot out=tprimetot prefix=cnt_ ;

by primedr ;

id total ;

var count ;

run ;

 

proc print data=tprimetot ;

title 'TRANSPOSED PRIME DR TOTAL' ;

run ;

 

proc transpose data=healthtot out=thealthtot prefix=cnt_ ;

by healthcd ;

id total ;

var count ;

run ;

 

proc print data=thealthtot ;

title 'TRANSPOSED HEALTH CD TOTAL' ;

run ;

 

proc transpose data=coldtot out=tcoldtot prefix=cnt_ ;

by cold ;

id total ;

var count ;

run ;

 

proc print data=tcoldtot ;

title 'TRANSPOSED COLD TOTAL' ;

run ;

 

proc transpose data=misstot out=tmisstot prefix=cnt_ ;

by misswork ;

id total ;

var count ;

run ;

 

proc print data=tmisstot ;

title 'TRANSPOSED MISS WORK TOTAL' ;

run ;

 

proc transpose data=hightot out= thightot prefix=cnt_ ;

by highbp ;

id total ;

var count ;

run ;

 

proc print data=thightot ;

title 'TRANSPOSED HIGH BP TOTAL' ;

run ;

 

proc transpose data=bptot out=tbptot prefix=cnt_ ;

by bpmeds ;

id total ;

var count ;

run ;

 

proc print data=tbptot ;

title 'TRANSPOSED BP MEDS TOTAL' ;

run ;

 

proc transpose data=checktot out=tchecktot prefix=cnt_ ;

by checkupcd ;

id total ;

var count ;

run ;

 

proc print data=tchecktot ;

title 'TRANSPOSED CHECK TOTAL' ;

run ;

 

**----- ADD DENOMINATORS TO COUNTS AND CALCULATE PERCENTS -----**;

data mergedenom ;

merge denoms totdenoms ;

by _name_ ;

run ;

 

data tprimecnt (drop=_label_);

   merge tprimecnt primetot mergedenom ;

   by _name_ ;

   if cnt_1 gt . then pct_1 = round( (cnt_1/den_1)*100, .1) ;

                 else cnt_1 = 0 ;

   if cnt_2 gt . then pct_2 = round( (cnt_2/den_2)*100, .1) ;

                 else cnt_2 = 0 ;

   if cnt_3 gt . then pct_3 = round( (cnt_3/den_3)*100, .1) ;

                 else cnt_3 = 0 ;

  

   if cnt_1000 gt . then pct_1000 = round( (cnt_1000/den_1000)*100, .1) ;

                 else cnt_1000 = 0 ;

  

   npct_1 = '(' || compress(put(pct_1,5.1)) || ')' ;

   npct_2 = '(' || compress(put(pct_2,5.1)) || ')' ;

   npct_3 = '(' || compress(put(pct_3,5.1)) || ')' ;

npct_1000 = '(' || compress(put(pct_1000,5.1)) || ')' ;

run ;

 

proc print data=tprimecnt ;

title 'PRIME DR BY REGION W/PCT' ;

run ;

 

data thealthcnt (drop=_label_);

   merge thealthcnt healthtot mergedenom ;

   by _name_ ;

   if cnt_1 gt . then pct_1 = round( (cnt_1/den_1)*100, .1) ;

                 else cnt_1 = 0 ;

   if cnt_2 gt . then pct_2 = round( (cnt_2/den_2)*100, .1) ;

                 else cnt_2 = 0 ;

   if cnt_3 gt . then pct_3 = round( (cnt_3/den_3)*100, .1) ;

                 else cnt_3 = 0 ;

  

    if cnt_1000 gt . then pct_1000 = round( (cnt_1000/den_1000)*100, .1) ;

                 else cnt_1000 = 0 ;

  

   npct_1 = '(' || compress(put(pct_1,5.1)) || ')' ;

   npct_2 = '(' || compress(put(pct_2,5.1)) || ')' ;

   npct_3 = '(' || compress(put(pct_3,5.1)) || ')' ;

npct_1000 = '(' || compress(put(pct_1000,5.1)) || ')' ;

run ;

 

proc print data=thealthcnt ;

title 'HEALTH BY REGION W/PCT' ;

run ;

 

data tcoldcnt (drop=_label_);

   merge tcoldcnt coldtot mergedenom ;

   by _name_ ;

   if cnt_1 gt . then pct_1 = round( (cnt_1/den_1)*100, .1) ;

                 else cnt_1 = 0 ;

   if cnt_2 gt . then pct_2 = round( (cnt_2/den_2)*100, .1) ;

                 else cnt_2 = 0 ;

   if cnt_3 gt . then pct_3 = round( (cnt_3/den_3)*100, .1) ;

                 else cnt_3 = 0 ;

  

   if cnt_1000 gt . then pct_1000 = round( (cnt_1000/den_1000)*100, .1) ;

                 else cnt_1000 = 0 ;

  

   npct_1 = '(' || compress(put(pct_1,5.1)) || ')' ;

   npct_2 = '(' || compress(put(pct_2,5.1)) || ')' ;

   npct_3 = '(' || compress(put(pct_3,5.1)) || ')' ;

npct_1000 = '(' || compress(put(pct_1000,5.1)) || ')' ;

run ;

 

proc print data=tcoldcnt ;

title 'COLD COUNT BY REGION W/PCT' ;

run ;

 

data tmisscnt (drop=_label_);

   merge tmisscnt misstot mergedenom ;

   by _name_ ;

   if cnt_1 gt . then pct_1 = round( (cnt_1/den_1)*100, .1) ;

                 else cnt_1 = 0 ;

   if cnt_2 gt . then pct_2 = round( (cnt_2/den_2)*100, .1) ;

                 else cnt_2 = 0 ;

   if cnt_3 gt . then pct_3 = round( (cnt_3/den_3)*100, .1) ;

                 else cnt_3 = 0 ;

  

   if cnt_1000 gt . then pct_1000 = round( (cnt_1000/den_1000)*100, .1) ;

                 else cnt_1000 = 0 ;

  

   npct_1 = '(' || compress(put(pct_1,5.1)) || ')' ;

   npct_2 = '(' || compress(put(pct_2,5.1)) || ')' ;

   npct_3 = '(' || compress(put(pct_3,5.1)) || ')' ;

npct_1000 = '(' || compress(put(pct_1000,5.1)) || ')' ;

run ;

 

proc print data=tmisscnt ;

title 'MISSWORK COUNT BY REGION W/PCT' ;

run ;

 

data thighcnt (drop=_label_);

   merge thighcnt hightot mergedenom ;

   by _name_ ;

   if cnt_1 gt . then pct_1 = round( (cnt_1/den_1)*100, .1) ;

                 else cnt_1 = 0 ;

   if cnt_2 gt . then pct_2 = round( (cnt_2/den_2)*100, .1) ;

                 else cnt_2 = 0 ;

   if cnt_3 gt . then pct_3 = round( (cnt_3/den_3)*100, .1) ;

                 else cnt_3 = 0 ;

  

   if cnt_1000 gt . then pct_1000 = round( (cnt_1000/den_1000)*100, .1) ;

                 else cnt_1000 = 0 ;

  

   npct_1 = '(' || compress(put(pct_1,5.1)) || ')' ;

   npct_2 = '(' || compress(put(pct_2,5.1)) || ')' ;

   npct_3 = '(' || compress(put(pct_3,5.1)) || ')' ;

npct_1000 = '(' || compress(put(pct_1000,5.1)) || ')' ;

run ;

 

proc print data=thighcnt ;

title 'HIGH BP COUNT BY REGION W/PCT' ;

run ;

 

data tbpcnt (drop=_label_);

   merge tbpcnt bptot mergedenom ;

   by _name_ ;

   if cnt_1 gt . then pct_1 = round( (cnt_1/den_1)*100, .1) ;

                 else cnt_1 = 0 ;

   if cnt_2 gt . then pct_2 = round( (cnt_2/den_2)*100, .1) ;

                 else cnt_2 = 0 ;

   if cnt_3 gt . then pct_3 = round( (cnt_3/den_3)*100, .1) ;

                 else cnt_3 = 0 ;

  

   if cnt_1000 gt . then pct_1000 = round( (cnt_1000/den_1000)*100, .1) ;

                 else cnt_1000 = 0 ;

  

   npct_1 = '(' || compress(put(pct_1,5.1)) || ')' ;

   npct_2 = '(' || compress(put(pct_2,5.1)) || ')' ;

   npct_3 = '(' || compress(put(pct_3,5.1)) || ')' ;

npct_1000 = '(' || compress(put(pct_1000,5.1)) || ')' ;

run ;

 

proc print data=tbpcnt ;

title 'BP MEDS COUNT BY REGION W/PCT' ;

run ;

 

data tcheckcnt (drop=_label_);

   merge tcheckcnt checktot mergedenom ;

   by _name_ ;

   if cnt_1 gt . then pct_1 = round( (cnt_1/den_1)*100, .1) ;

                 else cnt_1 = 0 ;

   if cnt_2 gt . then pct_2 = round( (cnt_2/den_2)*100, .1) ;

                 else cnt_2 = 0 ;

   if cnt_3 gt . then pct_3 = round( (cnt_3/den_3)*100, .1) ;

                 else cnt_3 = 0 ;

  

   if cnt_1000 gt . then pct_1000 = round( (cnt_1000/den_1000)*100, .1) ;

                 else cnt_1000 = 0 ;

  

   npct_1 = '(' || compress(put(pct_1,5.1)) || ')' ;

   npct_2 = '(' || compress(put(pct_2,5.1)) || ')' ;

   npct_3 = '(' || compress(put(pct_3,5.1)) || ')' ;

npct_1000 = '(' || compress(put(pct_1000,5.1)) || ')' ;

run ;

 

proc print data=tcheckcnt ;

title 'CHECKUP COUNT BY REGION W/PCT' ;

run ;

 

data counts (drop=den: _name_) ;*REMOVES EVERYTHING THAT STARTS WITH DEN;

   set tprimecnt (in=inp)

       thealthcnt(in=inh)

  tcoldcnt  (in=inc)

  tmisscnt  (in=inm)

  thighcnt  (in=int)

  tbpcnt (in=inb)

  tcheckcnt (in=ink)

 

  ;

 

   length rowhead $55 ;

   if ina then

      do ;

         tcat = 3 ;

roword = input(primedr, primedrv.) ;

         rowhead = put(roword, primedrv.) ;

      end ;

   else if inf then

      do ;

         tcat = 4 ;

roword = input(healthcd, healthcdv.) ;

         rowhead = put(roword, healthcdv.) ;

if healthcd= . then roword=9 ;

      end ;

   else if ins then

      do ;

         tcat = 5 ;

roword = input(cold, coldv.) ;

rowhead = put (roword, coldv.) ;

      end ;

   else if inb then

      do ;

         tcat = 7 ;

roword  = input(highbp, highbpv.) ;

         rowhead = put (roword, highbpv.) ;

      end ;

   else if int then

      do ;

         tcat = 8 ;

roword = input (bpmeds, bpmedsv.) ;

rowhead= put (roword, bpmedsv.); 

      end ;

  else if int then

      do ;

         tcat = 9 ;

rowhead= put (checkupcd, checkupcdv.); 

roword =input (tobacco, checkupcdv.) ;

if checkupcd= . then roword=7 ;

 

      end ;

run ;

 

proc sort data=counts ;

by tcat roword ;

run ;

 

proc print data=counts ;

title 'FINAL COUNT DATA' ;

run ;

 

**-----WINE DATA-----**;

 

proc sort data=alldata out=winesort ;

by smclscd ;

run ;

 

proc means data= winesort noprint ;

by smclscd ;

var wine ;

output out=winesort ;

run ;

 

data winesort ;

set winesort;

         if _stat_ in("N" "MIN" "MAX") then wine = round(wine,1.) ;

    else if _stat_ = "STD"             then wine = round(wine,.01) ;

    else if _stat_ = "MEAN"            then wine = round(wine,.1) ;

run ;

 

proc print data = winesort ;

title 'ROUNDED WINE VALUE CHECK' ;

run ;

 

proc sort data=winesort ;

by _stat_ ;

run ;

 

proc transpose data=winesort out=twinesort prefix=cnt_ ;

id smclscd ;

by _stat_ ;

var wine ;

run ;

 

proc print data=twinesort ;

title 'CHECK TRANSPOSED WINE DATA' ;

run ;

 

proc sort data=alldata out=totalwine ;

by smclscd ;

run ;

 

proc means data=totalwine noprint ;

by total ;

var wine ;

output out= totalwine ;

run ;

 

proc print data= totalwine ;

title 'TOTAL WINE' ;

run ;

 

data totalwine ;

set totalwine ;

if _stat_ in("N" "MIN" "MAX"then wine = round(wine,1.) ;

    else if _stat_ = "STD"             then wine = round(wine,.01) ;

    else if _stat_ = "MEAN"            then wine = round(wine,.1) ;

run ;

 

proc print data=totalwine ;

title 'CHECK TOTAL WINE ROUNDED VALUES' ;

run ;

 

proc sort data=totalwine ;

by _stat_ ;

run ;

 

proc transpose data=totalwine out=totalwinet prefix=cnt_ ;

id total ;

by _stat_ ;

var wine ;

run ;

 

proc print data=totalwinet ;

title 'TRANSPOSED TOTAL WINE'

run ;

 

**-----ALCOHOL DATA-----**;

 

proc sort data=alldata out=totalalc ;

by smclscd ;

run ;

 

proc means data=totalalc noprint ;

by total ;

var alcohol ;

output out=totalalc ;

run ;

 

proc print data=totalalc ;

title 'CHECK TOTAL ALC' ;

run ;

 

data totalalc ;

set totalalc ;

         if _stat_ in("N" "MIN" "MAX") then alcohol = round(alcohol,1.) ;

    else if _stat_ = "STD"             then alcohol = round(alcohol,.01) ;

    else if _stat_ = "MEAN"            then alcohol = round(alcohol,.1) ;

run ;

 

proc print data=totalalc ;

title 'CHECK TOTAL ALC ROUNDED VALUES' ;

run ;

 

proc sort data=totalalc ;

by _stat_ ;

run ;

 

proc transpose data=totalalc out=totalalct prefix=cnt_ ;

id total ;

by _stat_ ;

var alcohol ;

run ;

 

proc print data=totalalct ;

title 'CHECK TRANSPOSED TOTALALC DATA' ;

run ;

 

**---ALCOHOL DATA---**;

 

proc sort data=alldata out=allalcdata ;

by smclscd ;

run ;

 

proc means data=allalcdata noprint ;

by total ;

var alcohol ;

output out=allalcdata ;

run ;

 

proc print data=allalcdata ;

title 'ALCOHOL CHECK' ;

run ;

 

data allalcdata ;

set allalcdata ;

         if _stat_ in("N" "MIN" "MAX") then alcohol = round(alcohol,1.) ;

    else if _stat_ = "STD"             then alcohol = round(alcohol,.01) ;

    else if _stat_ = "MEAN"            then alcohol = round(alcohol,.1) ;

run ;

 

proc print data = allalcdata ;

title 'CHECK ALCOHOL ROUNDED VALUES' ;

run ;

 

 

proc sort data = allalcdata  ;

by _stat_ ;

run ;

 

proc transpose data = allalcdata out = tallalcdata prefix = cnt_;

id total ;

by _stat_ ;

var alcohol ;

run ;

 

proc print data=tallalcdata ;

title 'TRANSPOSED ALCOHOL DATA CHECK' ;

run ;

 

**-----MISSWORK DATA-----**;

 

data daysoff (where=(cold= 'Y')) ;

set totalalct ;

run ;

 

proc sort data=daysoff out=daysoff ;

by smclscd ;

run ;

 

proc means data=daysoff noprint ;

by smclscd ;

var misswork ;

output out=daysoff ;

run ;

 

proc print data=daysoff ;

title 'MISSED WORK DAYS' ;

run ;

 

data daysoff ;

set daysoff;

         if _stat_ in("N" "MIN" "MAX") then misswork = round(misswork,1.) ;

    else if _stat_ = "STD"             then misswork = round(misswork,.01) ;

    else if _stat_ = "MEAN"            then misswork = round(misswork,.1) ;

run ;

 

proc print data = daysoff ;

title 'MISSED WORK ROUNDED VALUE CHECK' ;

run ;

 

proc sort data = daysoff ;

by _stat_ ;

run ;

 

proc transpose data = daysoff out = tdaysoff prefix = cnt_;

id smclscd ;

by _stat_ ;

var misswork ;

run ;

 

proc print data=tdaysoff ;

title 'TRANSPOSED MISSED WORK DATA' ;

run ;

 

**-----TOTALS FOR MISSWORK-----**;

 

 

data totdaysoff (where=(cold = 'Y')) ;

set alldata ;

run;

 

proc sort data = totdaysoff out=totdaysoff;

by smclscd ;

run;

 

proc means data = totdaysoff  noprint;

by total ;

var misswork ;

output out = totdaysoff ;

run ;

 

proc print data = totdaysoff ;

title 'TOTAL DAYS OFF' ;

run ;

 

data totdaysoff ;

set totdaysoff ;

         if _stat_ in("N" "MIN" "MAX") then misswork = round(misswork,1.) ;

    else if _stat_ = "STD"             then misswork = round(misswork,.01) ;

    else if _stat_ = "MEAN"            then misswork = round(misswork,.1) ;

run ;

 

proc print data = totdaysoff ;

title 'CHECK ROUNDED DAYS OFF VALUES' ;

run ;

 

proc sort data = totdaysoff  ;

by _stat_ ;

run ;

 

proc transpose data = totdaysoff out = totdaysofft prefix = cnt_;

id total ;

by _stat_ ;

var misswork ;

run ;

 

proc print data = totdaysofft ;

title 'CHECK TRANSPOSED TOTAL ALC DATA' ;

run ;

 

 

**---WINE AND DAYS OFF MERGE---**;

 

data allwine ;

merge totalwinet totwinedata ;

by _stat_ ;

run;

 

proc print data=allwine ;

run;

 

data allwine ;

set allwine ;

    roword  = input(_stat_, mstats.) ;

    rowhead = put(roword, mstats.) ;

    tcat = 1 ;

run ;

 

proc print data = allwine ;

title "CHECK DATA FOR WINE" ;

run ;

 

/*MERGE SMCLSCD AND TOTAL ALCH CALCS*/

 

data allalc ;

merge tallalcdata totalalct ;

by _stat_ ;

run;

 

proc print data=allalc ;

run;

 

data allalc ;

set allalc ;

    roword  = input(_stat_, mstatsv.) ;

    rowhead = put(roword, mstatsv.) ;

    tcat = 2 ;

run ;

 

proc print data = allalc ;

title 'CHECK ALCHOLOL DATA' ;

run ;

 

**-----MISSWORK DATA MERGE-----**;

 

data nodaysoff ;

merge tdaysoff totdaysofft ;

by _stat_ ;

run;

 

proc print data=nodaysoff ;

run;

 

data nodaysoff ;

set nodaysoff ;

    roword  = input(_stat_, mstatsv.) ;

    rowhead = put(roword, mstatsv.) ;

    tcat = 6 ;

run ;

 

proc print data = nodaysoff ;

title "CHECK DATA FOR MISSWORK" ;

run ;

 

 

**----- COMBINE DATA FOR REPORT -----**;

 

proc sort data = allwine ;

by tcat roword ;

run ;

 

proc sort data = allalc ;

by tcat roword ;

run ;

 

proc sort data = nodaysoff ;

by tcat roword ;

run ;

 

data combine ;

set counts

allwine

allalc

nodaysoff ;

by tcat roword ;

run ;

 

proc print data = combine ;

title "CHECK FINAL TABLE" ;

run ;

 

 

**-----CONSOLIDATED COLUMNS-----**

 

data combine ;

set combine ;

column_1 = cnt_1 || '' || npct_1 ;

column_2 = cnt_2 || '' || npct_2 ;

column_3 = cnt_3 || '' || npct_3 ;

column_4 = cnt_1000 || '' || npct_1000 ;

run;

 

proc print data =combine ;

var column_1 ;

run ;

 

 

**-----CREATE RTF TABLE-----**;

 

 

 

options nodate nonumber missing = " ";

ods listing close ;

ods escapechar='^' ;

ods rtf file= ;

        style=tstylertf ;

 

title font='Times' height=12pt "^R'\ql 'Title Here";

title3 "^R'\ul 'Table 3:" ;

footnote "^{style [outputwidth=100% bordertopcolor=black bordertopwidth=2pt]*Used as the denominator for Taking Medication Percentages.}" ;

 

proc report data=combine nowd split="|" headline ;

   column tcat roword rowhead

          ("Current Smokers       (N=100)"  column_1)

          ("Non-        Smokers   (N=879)"  column_2)

          ("Past Smokers        (N=26)"   column_3)

  ("Total       (N=1005)" column_4)

          ;

   define tcat    / order noprint ;

   define roword  / order noprint ;

   define rowhead / ' ' style(header)=[cellwidth=2.25in just=l]  ;

   define column_1   / "^R'\qc"   style(column)=[cellwidth=.9in just=c] center

   define column_2   / "^R'\qc"   style(column)=[cellwidth=.9in just=c] center;

   define column_3   / "^R'\qc"   style(column)=[cellwidth=.9in just=c] center;

   define column_4   / "^R'\qc"   style(column)=[cellwidth=.9in just=c] center;

   

 

   compute before tcat ;

      line tcat tcat. ;

   endcomp ;

 

    compute after tcat ;

      line ' ' ;

   endcomp ;

 

run ;

 

ods rtf close ;

ods listing ;

 

1 REPLY 1
Reeza
Super User

You really only need to include relevant code. I'm definitely not reading all your code.

 

It looks like your ODS RTF statement is incorrect, and no filename is specified. 

 

ods rtf file= ;
        style=tstylertf ;

It should be:

 

ods rtf file='/folders/myfolders/myfile.rtf' style=tstylertf;

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 836 views
  • 1 like
  • 2 in conversation