I was able to produce this
Thank you again for your assistance. The attached PDF file is the chart I was able to produce
Jack E Mohr
Since your x-axis is numeric, you are getting the "random" jittering. To get the "Turnip" type jitter, the x-axis needs to be discrete.
How do I make the numeric SAS variable, Year, a discrete variable? Can you point me to any documentation?
Here is the code I used to produced the attached graphic:
Try:
xaxis display=(nolabel) type=discrete;
If that does not work, create and use a new character column that contains the year.
A graph like the sample from the "Dartmouth Atlas" works for a small number of categories on th x-axis and also with a relatively small number of observations in each row. This method may not work for other cases as there may not be enough space to place all the dots in each row even with a very small 1 pixel dot. It helps to have a graph that can scale to handle different data.
In the graph below, the observations in each horizontal bin are displayed using a bar where the length of the bar is proportional to the number of observations. Each observation is not shown, but the count in each bin can be shown (not necessary). This process is scalable to any number of categories on the x-axis and any number of observations in each row (bin). I will post the code shortly.
.
There have been several discussions recently about overlaying scatter plots or series plots on top of box plots. I've summarized some of my thoughts and presented some examples on my blog:
There is a reference to jitterwidth, but I was unable to find an example or an explaination of how to use it.
Note: The Turnip Charts in the Dartmouth Atlas are produced using SAS. They have 306 observations which is the same number I have in my data for each year. There must be a way to set parameters in SAS to disperse the points in the Turnip Chart
Even when I plot data for just one year, the dots overlap and are not spread out much
Here is the SAS code I used:
Your Blog post with code is interesting.
I would like to adapt the code you posted to my data, but was unable to make it work. Perhaps, the way my dataset is formatted is problematic, or the code needs to be modified to reflect the characteristics of my data.
I have attached an excell file that was created by exporting the SAS data set, MEDDISCH93TO13.
Can the graphics shown in your blog post be created using MEDDISCH93TO13? I suspect I have missed something simple
Jack Mohr
Asheville, NC
%let gpath='.';
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
/*--Read datra from Excel--*/
proc import datafile='C:\MEDDISCH93TO13.xlsx'
dbms=XLSX out=ExcelData replace;
run;
/*--Get bin counts by year--*/
ods output sgpanel=dataExcel;
ods graphics / reset imagename='HistPanelExcel';
proc sgpanel data=ExcelData(where=(year>2006));
panelby year / layout=rowlattice rows=4 novarname;
histogram BacterialPneumoniaDisch1k9313 / scale=count binwidth=1;
run;
/*--Keep only non-zero bins--*/
data nonzero;
set dataExcel (rename=(BIN_BACTERIALPNEUMONIADISCH1K__X=y
BIN_BACTERIALPNEUMONIADISCH1K__Y=max));
if max>0;
zero=0;
ylbl=0;
run;
/*--Make mirrored data for a HighLow plot--*/
data turnip;
length label $40;
set nonzero;
by year;
if first.year then label=year;
min=-max;
run;
/*--Create Spark-Plug Graph--*/
ods graphics / reset width=5in height=3in imagename='TurnipPanelExcel';
title 'Distribution of BACTERIALPNEUMONIADISCH1K by Year';
proc sgpanel data=turnip noautolegend;
panelby year / novarname layout=columnlattice
columns=4 noborder noheader;
highlow y=y low=min high=max / type=bar barwidth=1
fillattrs=(color=lightgray) lineattrs=(color=black);
colaxis display=none;
rowaxis offsetmin=0.15 display=(noticks noline nolabel) grid;
text y=y x=zero text=max / strip textattrs=(size=5);
text y=ylbl x=zero text=label / strip splitpolicy=split
position=bottom contributeoffsets=none;
run;
Update on Turnip Chart: https://blogs.sas.com/content/graphicallyspeaking/2017/10/23/turnip-plot-redux/
I was given this code for making turnip graphs. Can you make sense of this code?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.