BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
grezek
Obsidian | Level 7

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 

 

1 ACCEPTED SOLUTION

Accepted Solutions
grezek
Obsidian | Level 7

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 ;

View solution in original post

7 REPLIES 7
PGStats
Opal | Level 21

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.

PG
grezek
Obsidian | Level 7

This looks promising, but I couldn't figure out how to get it to work with SGPanel.  Thank you!

DanH_sas
SAS Super FREQ

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.

grezek
Obsidian | Level 7

Thank you!

Rick_SAS
SAS Super FREQ

The PANELBY statement supports the UNISCALE option, which determines whether the plots share a common X axis, Y axis, or both.

 

DanH_sas
SAS Super FREQ

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

grezek
Obsidian | Level 7

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 ;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 3981 views
  • 5 likes
  • 4 in conversation