Data visualization with SAS programming

BY statement and GTL

Reply
Contributor
Posts: 73

BY statement and GTL

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
N/A
Posts: 0

Re: BY statement and GTL

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
SAS Super FREQ
Posts: 890

Re: BY statement and GTL

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
Contributor
Posts: 73

Re: BY statement and GTL

ok thanks.
N/A
Posts: 0

Re: BY statement and GTL

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 heightSmiley Happy;
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;
Contributor
Posts: 73

Re: BY statement and GTL

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 ?
Ask a Question
Discussion stats
  • 5 replies
  • 180 views
  • 0 likes
  • 3 in conversation