Hi, I need to create a report in a format like below using the given data but I'm new to this. Any sample codes or advice would be greatly appreciated!
Given data:
LEADING CAUSES OF DEATH IN STATE OF TENNESSEE, ALL AGES TENNESSEE RESIDENT DATA, 2014-2017 Leading Cause Deaths TOTAL DEATHS 268881 DISEASES OF HEART 62317 MALIGNANT NEOPLASMS 57083 CHRONIC LOWER RESPIRATORY DISEASES 17177 ACCIDENTS AND ADVERSE EFFECTS 16282 CEREBROVASCULAR DISEASE 13792 ALZHEIMER'S DISEASE 12552 DIABETES MELLITUS 7315 PNEUMONIA AND INFLUENZA 6503 NEPHRITIS,NEPHROTIC SYNDROME,NEPHROSIS 4406 SUICIDE 4283 CHRONIC LIVER DISEASE AND CIRRHOSIS 3870 SEPTICEMIA 3671 OTHER DISEASES OF RESPIRATORY SYSTEM 3420 HYPERTENSION AND RENAL DISEASE 2686 PARKINSON'S DISEASE 2490 PNEUMONITIS DUE TO SOLIDS AND LIQUIDS 2251 ASSAULT (HOMICIDE) 1946 OTHER DISEASES OF CIRCULATORY SYSTEM 1902 BENIGN NEOPLASMS 1321 CERTAIN PERINATAL CONDITIONS 1014 CERTAIN OTHER INTESTINAL INFECTIONS 972 CONGENITAL ANOMALIES 968 VIRAL HEPATITIS 849 HUMAN IMMUNODEFICIENCY VIRUS (HIV) DIS 572 ALL OTHER INFECTIOUS AND PARASITIC DIS 572 NUTRITIONAL DEFICIENCIES 503 EVENTS OF UNDETERMINED INTENT 503 OTHER DISORDERS OF CIRCULATORY SYSTEM 478 ANEMIAS 440 COMPLICATIONS OF MEDICAL & SURGICAL CARE 367 ATHEROSCLEROSIS 350 CHOLELITHIASIS AND OTHER DISORDERS OF GALLBLADDER 348 PEPTIC ULCER 309 HERNIA 200 PREGNANCY, CHILDBIRTH AND THE PUERPERIUM 117
Please try the style(header) option in the proc report to change the back ground color and text color. Also call define to change the background color of columns displayed.
Here i generated the HTML file, you can try PDF as well.
ods html file='~/sample.html';
PROC REPORT DATA=WORK.HAVE LS=143 PS=30 SPLIT="/" CENTER style(header)=header{BACKGROUND=BLUE};
COLUMN leading_cause deaths;
DEFINE leading_cause / DISPLAY FORMAT= $36. WIDTH=36 SPACING=2 LEFT "Leading Cause" style(header)=header{color=white};
DEFINE deaths / FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Deaths" style(header)=header{color=white};
COMPUTE leading_cause;
CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=LIGHTGREEN]");
ENDCOMP;
COMPUTE deaths;
CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=LIGHTGREEN]");
ENDCOMP;
RUN;
ods html close;
you can try something as below and you can change the ods destination as per your requirement , here i used html destination
ods html body='deaths.html';
title 'LEADING CAUSES OF DEATH IN STATE OF TENNESSEE, ALL AGES TENNESSEE RESIDENT DATA, 2014-2017';
proc report data=have;
column leading_death deaths;
define leading_death / display width=100;
define deaths / display width=20;
run;
ods html close;
Please try the style(header) option in the proc report to change the back ground color and text color. Also call define to change the background color of columns displayed.
Here i generated the HTML file, you can try PDF as well.
ods html file='~/sample.html';
PROC REPORT DATA=WORK.HAVE LS=143 PS=30 SPLIT="/" CENTER style(header)=header{BACKGROUND=BLUE};
COLUMN leading_cause deaths;
DEFINE leading_cause / DISPLAY FORMAT= $36. WIDTH=36 SPACING=2 LEFT "Leading Cause" style(header)=header{color=white};
DEFINE deaths / FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Deaths" style(header)=header{color=white};
COMPUTE leading_cause;
CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=LIGHTGREEN]");
ENDCOMP;
COMPUTE deaths;
CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=LIGHTGREEN]");
ENDCOMP;
RUN;
ods html close;
I have another question. How do I remove the gridlines?
Think you just need the COMMA format. Make it wide enough to be applied to the TOTAL DEATHS which will have the largest number. Taking a small sample from your data. Is this what you are looking for?
data have ; length leading_cause $36 deaths 8 ; input @1 leading_cause $char36. deaths ; cards ; TOTAL DEATHS 268881 DISEASES OF HEART 62317 MALIGNANT NEOPLASMS 57083 CHRONIC LOWER RESPIRATORY DISEASES 17177 ACCIDENTS AND ADVERSE EFFECTS 16282 CEREBROVASCULAR DISEASE 13792 ; run ; proc print noobs data = have ; var leading_cause deaths ; format deaths comma10. ; run ;
Is this a HTML, RTF or some other output? Get familiar with ODS STYLE templates here: https://documentation.sas.com/?docsetId=odsug&docsetTarget=n13ivejjjk8flyn1jajj8onc3xnw.htm&docsetVe...
I have used the PDF destination with FestivalPrinter as an example (see attached). You will need to experiment with the various styles in the document I mentioned to figure out which one you need. If there isn't one that is suitable, it gets tricky. You may have to go with a custom style and that will require some learning.
ods pdf file="&mypath./deaths.pdf" style=FestivalPrinter ;
proc print noobs data = have ;
var leading_cause deaths ;
format deaths comma10. ;
run ;
ods pdf close ;
Hi @Amy0223
As the report is quite "simple", PROC PRINT provides good alternative to PROC REPORT:
proc print noobs data = have label
style(data)={backgroundcolor=lilg}
style(header)={backgroundcolor=skyblue color=white fontweight=bold};
var leading_cause deaths;
label leading_cause = "Leading Cause" deaths = "Deaths";
format deaths comma10. ;
title j=c color=black "Leading Causes of Death, Tennessee, Resident Data, 2014-2017";
run ;
Thank you so much! Is there a way to remove the gridlines?
you can try to use style=mystyle option in ods statement and also style(report)=[rules=none frame=void]
ods html file='~/sample.html' style=mystyle;
PROC REPORT DATA=WORK.HAVE LS=143 PS=30 SPLIT="/" CENTER style(header)=header{BACKGROUND=BLUE} style(report)=[rules=none frame=void];
COLUMN leading_cause deaths;
DEFINE leading_cause / DISPLAY FORMAT= $36. WIDTH=36 SPACING=2 LEFT "Leading Cause" style(header)=header{color=white};
DEFINE deaths / FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Deaths" style(header)=header{color=white};
COMPUTE leading_cause;
CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=LIGHTGREEN]");
ENDCOMP;
COMPUTE deaths;
CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=LIGHTGREEN]");
ENDCOMP;
RUN;
ods html close;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.