BookmarkSubscribeRSS Feed
Stephane
Quartz | Level 8
Hi

I used the proc greplay to order several graphs on a same page after to have created them with a proc gplot + BY statement.

Now, again with SAS 9.1, I'd like to know if the GTL could simplify this process. I'm not sure because I turn around the GROUP= statement and datagrid without success.

Some of you have a idea or the good way to do that for example
I start with a proc gplot and a BY statement. I'd like a template to distribut each graphic on a grid (in order to have them on one page only) :

proc gplot data=sashelp.class;
by age;
plot weight*height;
run;

Stéphane. Message was edited by: Stephane
5 REPLIES 5
deleted_user
Not applicable
Hi,

You can use PROC SGPANEL to create a plot for each value of the "BY" variable.

* Sorting by PANELBY variable not required;
proc sgpanel data=sashelp.class;
panelby age;
scatter x=height y=weight;
run;

You can use the template browser to view the generated GTL in the WORK library.

-Randy
DanH_sas
SAS Super FREQ
Unfortunately, the pre-production version of GTL in 9.1 did not have the ability to panel plots based on classification. In 9.1, you would need to split the data into separate columns based on the BY-group value and use a Layout Lattice in GTL.

Thanks!
Dan
Stephane
Quartz | Level 8
ok thanks.
deleted_user
Not applicable
Hi,

I don't have a copy of SAS 9.1 to test this code, but I did get a modified version to work with 9.2 (9.2 has begingraph/endgraph blocks, the lattice layout option rowdatarange instead of hrange, and PROC SGRENDER). Depending on the status of dynamic variables as of 9.1, you might be able to use one for the ENTRY statements' text.

-Randy

data class(drop=height keep=weight height:);
set sashelp.class;
select (age);
when (11) height11=height;
when (12) height12=height;
when (13) height13=height;
when (14) height14=height;
when (15) height15=height;
when (16) height16=height;
otherwise;
end;
run;

ods graphics on;

proc template;
define statgraph lattice_test;

layout lattice / columns=2 columngutter=5 rowgutter=5 vrange=unionall;

cell;
cellheader;
entry "Age 11";
endcellheader;
scatterplot x=weight y=height11;
endcell;

cell;
cellheader;
entry "Age 12";
endcellheader;
scatterplot x=weight y=height12;
endcell;

cell;
cellheader;
entry "Age 13";
endcellheader;
scatterplot x=weight y=height13;
endcell;

cell;
cellheader;
entry "Age 14";
endcellheader;
scatterplot x=weight y=height14;
endcell;

cell;
cellheader;
entry "Age 15";
endcellheader;
scatterplot x=weight y=height15;
endcell;

cell;
cellheader;
entry "Age 16";
endcellheader;
scatterplot x=weight y=height16;
endcell;

endlayout;

end;
run;


data _null_;
set class;
attrib weight label='Weight' height: label='Height';
file print ods=(template='lattice_test');
put _ods_;
run;
Stephane
Quartz | Level 8
that's interesting Randy thanks. I developped a macro that count the number of graphs and to create dynamically the greplay grid.
I wanted to find a way with GTL to do that and this is the Proc SGPANEL I think because if I assume to industrialise your last proposition I will do a similar macro program.

A new reason to go to SAS 9.2 for my client isn't it ?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1338 views
  • 0 likes
  • 3 in conversation