I am trying to get SGPanel to produce a scatter plot graphs in 4 panels with different x-axis scales. I divide the data into 4 groups of x-values--the by statement divides the data such that each panel displays the entire common range (see attach). Is it possible to have each panel with its own range such that the detail within the range is clearer.
The code I use:
ods rtf body="K:\MRM\Model ...\graphs\AVM vs. True Scatterplot by &name..rtf";
proc sgpanel data=&lib..reg ;
panelby &by. / /*uniscale=row*/ sort =data ;
* scatter x=lastsaleprice y=avm_value / ;
reg x=lastsaleprice y=avm_value / cli /*nomarkers*/ lineattrs=(color=red);
format avm_value cpred dollar12.0;
*colaxis min=0 max=1750000;
* rowaxis min=0 max=1750000;
TITLE "AVM vs. True Scatterplot by &name";
run;
ods rtf close ;
The image I'm getting is attached. Any suggestions are welcome. Thanks for your help. -- George
Great suggestions and it got me almost there--were I more familiar with sgpanel maybe I could have figured it out. As it is, the best I could do is getting the desired output across two pages. I merged the plots with "keep with next" in Word (see attached) using (see below), which shows what I want to show. THANK YOU ALL VERY MUCH! You've been a big help! -- George
ods _all_ close ;
ods rtf body="K:\MRM\Model Validation\model_inventory\m0080_Corelogic_AVM\2021\5 Validation Testing\graphs\AVM vs. True Scatterplot by &name..rtf";
proc sgpanel data=&lib..reg ;
panelby &by. / uniscale=row LAYOUT=COLUMNLATTICE sort =data ;
* scatter x=lastsaleprice y=avm_value / ;
reg x=lastsaleprice y=avm_value / cli /*nomarkers*/ lineattrs=(color=red);
format avm_value cpred dollar12.0;
*colaxis min=0 max=1750000;
* rowaxis min=0 max=1750000;
TITLE "AVM vs. True Scatterplot by &name";
run;
ods rtf close ;
proc sgpanel is for making graph matrices (panels) that share axes. If you want a matrix of graphs that do not share axes, your best bet, I think, is ODS LAYOUT. Look at the ODS LAYOUT GRIDDED statement.
An alternative would be to plot all the data on the same graph, possibly with reflines to separate the x variable ranges.
This looks promising, but I couldn't figure out how to get it to work with SGPanel. Thank you!
What @PGStats was proposing was to use SGPLOT with a BY statement to create individual plots, and use ODS LAYOUT to lay them out on the page as desired. If you go that route, be sure to use the UNISCALE option on the PROC SGPLOT statement to force the Y axis to be uniform across BY-groups.
Thank you!
The PANELBY statement supports the UNISCALE option, which determines whether the plots share a common X axis, Y axis, or both.
In addition to the UNISCALE option mentioned by @Rick_SAS , you will also need to specify either LAYOUT=COLUMNLATTICE or COLUMN=4 to get the correct layout for your display. The LAYOUT option would be preferred here because you will always want all of the plots on the same row, regarding of the number of plots. You will also want to use the ONEPANEL option to turn off pagination to make sure all plots stay in the same graph.
Hope this helps!
Dan
Great suggestions and it got me almost there--were I more familiar with sgpanel maybe I could have figured it out. As it is, the best I could do is getting the desired output across two pages. I merged the plots with "keep with next" in Word (see attached) using (see below), which shows what I want to show. THANK YOU ALL VERY MUCH! You've been a big help! -- George
ods _all_ close ;
ods rtf body="K:\MRM\Model Validation\model_inventory\m0080_Corelogic_AVM\2021\5 Validation Testing\graphs\AVM vs. True Scatterplot by &name..rtf";
proc sgpanel data=&lib..reg ;
panelby &by. / uniscale=row LAYOUT=COLUMNLATTICE sort =data ;
* scatter x=lastsaleprice y=avm_value / ;
reg x=lastsaleprice y=avm_value / cli /*nomarkers*/ lineattrs=(color=red);
format avm_value cpred dollar12.0;
*colaxis min=0 max=1750000;
* rowaxis min=0 max=1750000;
TITLE "AVM vs. True Scatterplot by &name";
run;
ods rtf close ;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.