BookmarkSubscribeRSS Feed
DB_ECON
Calcite | Level 5
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
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
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
GraphGuy
Meteorite | Level 14
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!
DB_ECON
Calcite | Level 5
Thanks Cynthia and Robert for your suggestions...

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 3082 views
  • 0 likes
  • 3 in conversation