Data visualization with SAS programming

Use GPLOT Overlay option to plot multiple series

Reply
Contributor
Posts: 20

Use GPLOT Overlay option to plot multiple series

proc gplot data=abc;
plot x1*date ;
where x3='1: < 24';
by x4 ;
run;
quit;

x4 is a character variable. THe abovecode generates a separate graph for each value in x4. How do I overlay all the series in one graph
SAS Super FREQ
Posts: 8,720

Re: Use GPLOT Overlay option to plot multiple series

Hi:
Look at this example in the doc:
http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#/documentation/cd...

Of particular relevance to your question is the syntax:
[pre]
plot faren*month=city / .... more options ....;
[/pre]

cynthia
SAS Employee
Posts: 967

Re: Use GPLOT Overlay option to plot multiple series

There are basically 2 ways to overlay lines in gplot ...

As Cynthia mentioned, you can probably use "plot y*x=z" (where z is what you were using as the by variable).

Or, you can use something like "plot y1*x y2*x y3*x / overlay" - for this technique, you'd probably have to transpose your data, and it requires hard-coding all the (new) variable names in the plot statement. It's hard to get real specific without seeing the exact data, but basically you would have to transpose your data (proc transpose) so that you're basically turning the text values into variable names, with the x1 numeric values becoming the values of the new variables.

You'll probably want to go with Cynthia's technique, but just wanted to mention the 2nd alternative!
Contributor
Posts: 20

Re: Use GPLOT Overlay option to plot multiple series

Thanks Cynthia and Robert for your suggestions...
Ask a Question
Discussion stats
  • 3 replies
  • 843 views
  • 0 likes
  • 3 in conversation