BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Amy0223
Quartz | Level 8

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!

Screen Shot 2020-05-27 at 2.10.35 PM.png

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
1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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;

 

image.png

Thanks,
Jag

View solution in original post

12 REPLIES 12
Jagadishkatam
Amethyst | Level 16

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;

 

Thanks,
Jag
Amy0223
Quartz | Level 8
Thank you very much for helping me out. Do you know how to create the report with colors as shown above? I really appreciate it!
Jagadishkatam
Amethyst | Level 16

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;

 

image.png

Thanks,
Jag
Amy0223
Quartz | Level 8
This is such a great help! Thank you so much!!!
Amy0223
Quartz | Level 8

I have another question. How do I remove the gridlines?

biopharma
Quartz | Level 8

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 ;
 

 

Amy0223
Quartz | Level 8
Thank you for your kind help! I'm wondering how to create a report that shows the colors as shown in the picture. Any help is greatly appreciated. Thanks!
biopharma
Quartz | Level 8

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 ;

 

ed_sas_member
Meteorite | Level 14

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 ;

Capture d’écran 2020-05-28 à 13.17.57.png

Amy0223
Quartz | Level 8

Thank you so much! Is there a way to remove the gridlines?

Jagadishkatam
Amethyst | Level 16

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;

image.png

Thanks,
Jag
Amy0223
Quartz | Level 8
Thank you so much! Your information is very helpful! I greatly appreciate it.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 12 replies
  • 2288 views
  • 3 likes
  • 4 in conversation