04-23-2013 12:33 PM
Hello Sas users,
I would appreciate any advice you could give on generating a particular graph.
To summarize my data structure I have different environmental measurements taken at 5 sampling units at different distances from a forest edge (1, 5, 10 30 and 60 meters). This sampling procedure was repeated at 4 edges (N1, N2, S1 and S2) at 3 sites.
For each site, I want to summarize the changes in environmental variables that occur along each edge to interior transect.
I generated one “band” of this graph using sgpanel, with the following code, for the environmental measurement “avg elev”.
proc sgpanel data=EvElev_dist;
panelby pertrans / LAYOUT=columnlattice UNISCALE=COLUMN ONEPANEL;
scatter x=dist y=avgelev ;
colaxis label="Distance from edge";
rowaxis label="Relative elevation (cm), n=2"; run;
which produced the following graph:
Each column (n1, n2, etc) is a different edge specified by the variable “pertrans”, and the variable on the x axis of each graph is the distance from the edge (1, 5, 10, 30 or 60m).
WHAT I NEED is to make a graph where I have the response of different environmental variables (besides elevation) stacked one on top of another. Essentially, I want the exact format shown in the previous graph, for each different environmental variable. Then I want them stacked in a panel so that I can compare how different envirionmental variables change over each edge-interior transect.
Any advice you could offer would be much appreciated.
04-23-2013 12:56 PM
I don't have time to give a complete example, but let me outline an approach that might work. The basic idea is to move from "wide" format to "long" format. You want all of the response variables to be names VALUE and you want to create a new ID variable called VARIABLE that you can put on the PANELBY statement in order to build the vertical strata.
If the environmental variables are in different data sets, concatenate them together and create a new ID variable called VARIABLE.
For example, you might do something like this (code probably contains syntax errors):
set EvElev_dist(rename=(AveElev=Value) in=In1)
if in1 then Variable="Elevation";
else if in2 then Variable="Var2";
proc sgpanel data=All;
panelby pertrans Variable; /* VARIABLE is new PANELBY var */
scatter x=dist y=Value; /* VALUE is the response for all envornmental variables */
04-23-2013 02:21 PM
Sorry, one last question. I successfully generated that graph, but now am wondering if there is a way, within sgpanel, to scale the values of each row of graphs to match the range of values for that data. For instance, although all of the variables values are now stored in one field "value", the range for each type of measurement is vastly different. For instance some environmental measurements range 0-1, while others range 0-100. I am wondering if there is an "easy" way to make sgpanel automatically scale the graph axis to reflect the range of the variables it is graphing.
04-23-2013 02:27 PM
Nevermind, I figured it out. The answer was to specify uniscale=column.
proc sgpanel data=ALLenv_plots;
panelby pertrans var/ LAYOUT=lattice onepanel uniscale=column;
scatter x=partrans y=value ;