Hi,
I am trying to create a scatterplot for a dataset with two groups. Number of observations in one group are much fewer compared to the other group. When I plot this graph using sgplot, most of the plot area obviously is covered by the group with higher number of observations. Is there a way to adjust this such that the plot area is split into half for each group? I assume there will be some additional white space in the area where there aren't enough observations, which is okay.
My basic code for creating the graph is below:
proc sgplot data = dataset;
scatter x= Days y= ID /group = study_arm;
run;
Not automatically but you can split/break the axis based on your knowledge of the data.
proc sgplot data = dataset;
scatter x= Days y= ID /group = study_arm;
xaxis ranges=(min - someValue nextValue-high) values = (Min to Max by Interval);
run;
https://blogs.sas.com/content/graphicallyspeaking/2015/09/02/broken-axis-redux/
@analyst_work wrote:
Hi,
I am trying to create a scatterplot for a dataset with two groups. Number of observations in one group are much fewer compared to the other group. When I plot this graph using sgplot, most of the plot area obviously is covered by the group with higher number of observations. Is there a way to adjust this such that the plot area is split into half for each group? I assume there will be some additional white space in the area where there aren't enough observations, which is okay.
My basic code for creating the graph is below:
proc sgplot data = dataset;
scatter x= Days y= ID /group = study_arm;
run;
Another option might be SGPANEL creating one graph for each value of the group variable.
proc sgpanel data = dataset; panelby study_arm / onepanel uniscale=row columns=2 layout=columnlattice; scatter x= Days y= ID ; run;
The ONEPANEL option to force all the plots into one may be overkill, the Uniscale=row means that the vertical axis will be the same and allow different horizontal axis in each panel, Columns= should be the number of levels of the group variable. If the columns is more than 3 or 4 then you may need to play with ODS Graphics settings to provide a larger plot area.
By default each panel should be the same physical size.
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.