hi,
Anyone know how to set range for scatter plot in proc template?
I want to make two scatter plot side by side in proc template, with same x range and y range. how to do it?
Thanks
proc template;
define statgraph scatter;
layout gridded / columns=2 row=1;
layout overlay;
scatterplot x=height1 y=weight1;
endlayout;
layout overlay;
scatterplot x=height2 y=weight2;
endlayout ;
endlayout;
end;
run;
You'll want to use a LAYOUT LATTICE instead of a LAYOUT GRIDDED, and you will want to set the COLUMNDATARANGE and ROWDATARANGE to UNIONALL so that the data ranges from all cells are included in the axis range. Here is a simple example:
proc template;
define statgraph scatter;
begingraph;
layout lattice / columns=2 rows=1 columndatarange=unionall rowdatarange=unionall;
layout overlay;
scatterplot x=height1 y=weight1;
endlayout;
layout overlay;
scatterplot x=height2 y=weight2;
endlayout ;
endlayout;
endgraph;
end;
run;
data class;
set sashelp.class;
height1 =height;
weight1=weight;
height2=height*2;
weight2=weight*2;
run;
proc sgrender data=class template=scatter; run;
Hope this helps!
Dan
Set xaxisopts and yaxisopts.
See example below which is for a survival curve.
layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05
linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS
tickvaluefitpolicy=XTICKVALFITPOL)) yaxisopts=(label=
"Survival Probability" shortlabel="Survival" linearopts=(viewmin=
0 viewmax=1 tickvaluelist=(0 .2 .4 .6 .8 1.0)));
thanks for your help
You'll want to use a LAYOUT LATTICE instead of a LAYOUT GRIDDED, and you will want to set the COLUMNDATARANGE and ROWDATARANGE to UNIONALL so that the data ranges from all cells are included in the axis range. Here is a simple example:
proc template;
define statgraph scatter;
begingraph;
layout lattice / columns=2 rows=1 columndatarange=unionall rowdatarange=unionall;
layout overlay;
scatterplot x=height1 y=weight1;
endlayout;
layout overlay;
scatterplot x=height2 y=weight2;
endlayout ;
endlayout;
endgraph;
end;
run;
data class;
set sashelp.class;
height1 =height;
weight1=weight;
height2=height*2;
weight2=weight*2;
run;
proc sgrender data=class template=scatter; run;
Hope this helps!
Dan
Thanks, that helps
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: