I need to create a series of scatter plots four per page for laboratory parameters. They all need to be contained in one RTF and must have varying axis labels, titles and y-axis scales. Can this be done with SGPANEL?
@Doug____ wrote:
I need to create a series of scatter plots four per page for laboratory parameters. They all need to be contained in one RTF and must have varying axis labels, titles and y-axis scales. Can this be done with SGPANEL?
What have you tried?
When you say "four per page" do you mean a specific 2 by 2 graph layout, 4 separate, one graph panel with 4 graphs vertically or horizontally aligned?
With SGPANEL if you have graphs side-by-side they would have the same vertical axis definition. If you want side-by-side with different y scales you likely need to move to the Graphics Template Language and possibly a Layout LATTICE or Layout DATALATTICE structure.
Can you provide some data that represents what you want to graph as a data step that we could attempt?
I'm just getting started with it. The layout would be 2x2 per page and each graph would show baseline values on the x-axis and the visit of interest value on the y-axis. Each plot within the parameter would show a different visit. So for example page 1 would show the results for Platelets let's say for Visits 1, 2, 3, 4, then the second page would start at visit 5 - 8, etc. for as many as are needed. Then there would be a page break to the next parameter and it repeats. I don't have any example data so the x and y values could be any integer or floating point number depending on the test conducted.
In addition the axis values would be set once per parameter so all the plots look the same within the test analyzed. The y-axis labels would reflect at which visit the analysis takes place and would vary with each plot within the grid.
I ginned up the following dummy data so if I can get the code working for this then it will work for my example as well.
data x;
do trtp = "A", "B";
do i = 1 to 100;
paramcd = "X";
do visit = 1 to 4;
base = ranuni(-1)*10;
aval = ranuni(-1)*1000;
output;
end;
end;
do i = 1 to 100;
paramcd = "Y";
do visit = 1 to 7;
base = ranuni(-1)*40;
aval = ranuni(-1)*50;
output;
end;
end;
end;
run;
As there are differing attributes for each, I would suggest looking at gridded in graph template label:
With this, and dynamic variables you could have the four graphs, gridded, with labels and axis passed in by dynamic variables. Then you can call this template with a call execute from datastep with each block of data.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.