BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hi All,

 

If I use SGplot to make a plot with two different Y-axes, I love that I can use offsetmax and offsetmin to create distinct areas for each plot, rather than overlay them.

 

data have ;
  do time= 1 to 10 ;
    y1=rand('normal',0,1) ;
    y2=rand('normal',100,10) ;
    y3=rand('normal',1000,100) ;
    output;
  end;
run ;

proc sgplot data=have ;
  yaxis          
    offsetmax=0.6 /*bottom 40%*/  
    labelpos=DataCenter
  ;

  y2axis 
    offsetmin=0.6  /*top 40%*/
    labelpos=DataCenter
  ; 

  series x=time y=y1 ;
  series x=time y=y2 /y2axis ;
run ;

Which returns:

sgplot.PNG

 

Now I'm in the situation where I want to do the same thing, with 3 zones.  So I have Y1, Y2, Y3, which are all different attributes measured in different units, and I want a single plot with a shared time axis which shows how they all vary over time.  So like above, but with three zones (and ideally I'd like to control the height of each zone).

 

Is this possible with SGPLOT?  (I think no).

 

If not, I'm guessing it is possible if I get back into GTL, using layout lattice (maybe), and layout overlay to define each of the three plots?

 

Thanks,

-Q.

The Boston Area SAS Users Group is hosting free webinars!
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

A simpler way is to use SGPANEL procedure.  Mark the observations with three different classification values, say 1, 2, 3 in a column named 'Axis' or something.  Then use PANELBY=axis, with COLUMNS=1 or LAYOUT=ROWLATTICE.

View solution in original post

3 REPLIES 3
Jay54
Meteorite | Level 14

A simpler way is to use SGPANEL procedure.  Mark the observations with three different classification values, say 1, 2, 3 in a column named 'Axis' or something.  Then use PANELBY=axis, with COLUMNS=1 or LAYOUT=ROWLATTICE.

Quentin
Super User

Thanks @Jay54 , that makes sense.  I had thought briefly about SGPANEL, but dismissed it too quickly without realizing I could just transpose my data to create a categorical variable to PanelBy.  Will give it a try.

 

So glad to see you're still contributing on here!

The Boston Area SAS Users Group is hosting free webinars!
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
Quentin
Super User

Well, if I had just checked the example on p264 of your red book where you show vital signs (BP, pulse, temp) by time, that's pretty much what I was looking for...  Thanks again.

 

proc transpose data=have out=want ;
  by time ;
run ;

proc sgpanel  data=want ;
  panelby _name_ /layout=rowlattice onepanel novarname uniscale=column;
  series x=time y=col1 ;
  rowaxis display=(nolabel) ;
run ;

I still might end up delving into GTL to  be able to dictate the size of each panel.  But definitely good to keep SGPANEL in mind.

The Boston Area SAS Users Group is hosting free webinars!
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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
  • 1362 views
  • 1 like
  • 2 in conversation