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.
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
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.
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.
Thank you sir for your suggestions. I will move to using proc sgplot.
I appreciate the examples provided.
Take care.
wlierman
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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.