BookmarkSubscribeRSS Feed
Ram_SAS
Obsidian | Level 7

Hi,

Wondering is it possible to get the names just below the respective panel.  Thanks.

data dummy;
	set sashelp.class;
	do day=1 to 10;
		n=ranuni(50)+20  ;
		output;
	end;
run;

proc sgpanel data=dummy;  
	panelby sex /layout=columnlattice  uniscale=all  novarname colheaderpos=bottom ;
	series x=day y=n/group=name markers name="name"
		lineattrs=(thickness=1) markerattrs=(size=6) attrid=subjid;
	colaxis integer label="Day";
	rowaxis label="n";
	keylegend "name"/ title ="Name";
run;

SGPanel1.png

6 REPLIES 6
ballardw
Super User

Do you mean a separate legend with different values for female and male? If the Legend is more important than two side-by-side graphs then  easiest would be Proc SGPLOT and by sex:

proc sort data= dummy;
by sex;
run;

proc sgplot data=dummy;  
   by sex;
	series x=day y=n/group=name markers name="name"
		lineattrs=(thickness=1) markerattrs=(size=6) attrid=subjid;
	keylegend "name"/ title ="Name";
run;
Ram_SAS
Obsidian | Level 7

Yes. but that gives  two separate images.  I like to have both side by side on the same page.  Thanks. 

Jay54
Meteorite | Level 14

No.  With SGPANEL, the legend can only be outside the cell grid.  If you want two legends, one in each cell, you would have to construct the 2-cell LATTICE yourself using GTL LAYOUT LATTICE.

Getting Started example:  https://blogs.sas.com/content/graphicallyspeaking/2013/02/12/gtl-layouts/

DanH_sas
SAS Super FREQ

You could ODS LAYOUT to put the SGPLOT output side-by-side on the page.

Ram_SAS
Obsidian | Level 7

Need to learn GTL more in detail.  Tried ODS layout earlier, but did not work well.  Could you please provide some sample code for ODS layout.  What about proc gslide and proc greplay?  Thanks in advance.

 

Ram 

Reeza
Super User

If your graph is going to be as busy as the one you posted I would recommend an alternative. Add labels at the end or beginning of each series. Possibly both and have some displayed on either side to help with readability. Otherwise practically trying to read that won't work.  

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2431 views
  • 0 likes
  • 5 in conversation