BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wlierman
Lapis Lazuli | Level 10

I am producing multiple charts and tables weekly for a Covid Response and Recovery Unit.  The views are created from ARIAS (which is a Microsoft product).  Right now the graphics/charts/tabular analysis is in a beta stage in that leadership haven't decided upon what to use.  Once that is decided the presentations will go over to Tableau.

 

Anyway, I am producing a lot of charts and plots/graphics on the fly not worrying about the bells and whistles.

 

I have found that proc freq has enough graphics options so I can produce weekly reports with some presentable graphics. 

 

But there are little things that present a challenge. The attached code is to create a simple horizontal chart of number of contacts by county.

ods graphics on;

proc freq data = SASCDC_2.Arias_County_RC_ETHNICITY_A;
     table county_1 / plots (only) = freqplot (orient = horizontal scale = freq);
run;

ods graphics off;
                                            

The problem is how do I control the font size and also be sure that all 36 county names are shown on the y-axis.  Right now every other county name is printed.  So I have to make the font size a bit smaller or maybe stretch the axis a little. 

 

wlierman_0-1611350973126.png

Also how can I include the number of contacts for each county at the end of the horizontal bars?

 

Thank you for your help.

 

Wlierman

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

This may be the time to start using the actual graphing procedures to have more control.

Here is an example with a data set you should have:

proc sgplot data=sashelp.cars;
   hbar make /stat=freq  
             datalabel datalabelpos=data
             DATALABELFITPOLICY=NONE
   ;
   yaxis type=discrete fitpolicy=none ;
run;

You may want to use the ODS GRAPHICS  options height= and width= to provide a bit more room as well.

The above procedure lets you control the axis Valueattrs (color and font options for the tick mark text appearance)

There are lots of options to control order of bars such as:

proc sgplot data=sashelp.cars;
   hbar make /stat=freq  
             datalabel datalabelpos=data
             DATALABELFITPOLICY=NONE
             categoryorder=respdesc
   ;
   yaxis type=discrete fitpolicy=none ;
run;

Which has the data ordered with higher counts at the top .

Or subgroups of records:

proc sgplot data=sashelp.cars;
   hbar make /stat=freq  
              group=type  
             datalabel datalabelpos=data
             DATALABELFITPOLICY=NONE
             categoryorder=respdesc
   ;
   yaxis type=discrete fitpolicy=none ;
run;

For your purpose think confirmed/presumed positive test, no vaccination/ first shot/ completed vaccination (if two shots needed)

or similar.

 

View solution in original post

4 REPLIES 4
ballardw
Super User

This may be the time to start using the actual graphing procedures to have more control.

Here is an example with a data set you should have:

proc sgplot data=sashelp.cars;
   hbar make /stat=freq  
             datalabel datalabelpos=data
             DATALABELFITPOLICY=NONE
   ;
   yaxis type=discrete fitpolicy=none ;
run;

You may want to use the ODS GRAPHICS  options height= and width= to provide a bit more room as well.

The above procedure lets you control the axis Valueattrs (color and font options for the tick mark text appearance)

There are lots of options to control order of bars such as:

proc sgplot data=sashelp.cars;
   hbar make /stat=freq  
             datalabel datalabelpos=data
             DATALABELFITPOLICY=NONE
             categoryorder=respdesc
   ;
   yaxis type=discrete fitpolicy=none ;
run;

Which has the data ordered with higher counts at the top .

Or subgroups of records:

proc sgplot data=sashelp.cars;
   hbar make /stat=freq  
              group=type  
             datalabel datalabelpos=data
             DATALABELFITPOLICY=NONE
             categoryorder=respdesc
   ;
   yaxis type=discrete fitpolicy=none ;
run;

For your purpose think confirmed/presumed positive test, no vaccination/ first shot/ completed vaccination (if two shots needed)

or similar.

 

wlierman
Lapis Lazuli | Level 10

Thank you sir for your suggestions.  I will move to using proc sgplot.

 

I appreciate the examples provided.

 

Take care.

 

wlierman

Reeza
Super User
And as a quick FYI - you can play around with ODS style templates to get different default presentations without too much fussing around that are better than the default SAS BLUE. You control that with the STYLE= on your ODS statement.

Meadow, Seaside, Journal are a couple of the templates that I use, if I don't have time to customize my graphics.
There's also an Edward Tufte version someone created that's on here somewhere.

ods pdf ... style = meadow;

Some examples of the different styles are here:
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=odsadvug&docsetTarget=p14...
wlierman
Lapis Lazuli | Level 10

Thank you Reeza for your help. You have provided some effective time-saving solutions in the past.

 

I will explore the documentation link that you provided.

 

Take care.

 

wlierman

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1256 views
  • 3 likes
  • 3 in conversation