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

I have a finicky problem with laying out labels in a GTL datalattice.

 

This almost does what I want, with one problem: the sidebar 'Cat 1 Description' (which describes the rowheaders) should be to the left of the rowheaders 'Type A' and 'Type B', and I can't figure out how to get it there.

 

proc template;
define statgraph test;
	begingraph;
		layout datalattice rowvar=cat1 /
			row2axisopts=(label='Cat 2 Description')
			headerlabeldisplay=value headerlabellocation=outside rowheaders=left;
			sidebar / align=left;
				entry 'Cat 1 Description' / rotate=90;
			endsidebar;
			layout prototype;
				barchart x=cat2 y=pct_row /
					orient=horizontal yaxis=y2;
			endlayout;
		endlayout;
	endgraph;
end;

graph.png

This is the vertical bar equivalent, which is laid out just how I like it:

 

proc template;
define statgraph test;
	begingraph;
		layout datalattice columnvar=cat1 /
			columnaxisopts=(label='Cat 2 Description')
			headerlabeldisplay=value headerlabellocation=inside columnheaders=top;
			    sidebar / align=top;
					entry 'Cat 1 Description';
				endsidebar;
				layout prototype;
					barchart x=cat2 y=pct_row /
						orient=vertical;
				endlayout;
		endlayout;
	endgraph;
end;

Things I've tried that didn't work: headerlabellocation=inside (changes the row headers to be horizontal text at the top of the cell, at least in SAS 9.3); adding a cell with the row label text within a gridded layout (too much whitespace).

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Sometimes an inline annotation (DRAWTEXT) is what you need.

 

proc template;
  define statgraph test;
    begingraph;
      layout datalattice rowvar=cat1 / pad=(left=5pct)
                                 row2axisopts=(label='Cat 2 Description')
                                headerlabeldisplay=value headerlabellocation=outside rowheaders=left;
       drawtext "Cat 1 Description" / x=0 y=55 anchor=top rotate=90 width=50 drawspace=layoutpercent;

       layout prototype;
         barchart x=cat2 y=pct_row / orient=horizontal yaxis=y2;
      endlayout;
    endlayout;
  endgraph;
end;

 

data bar;
format pct_row percent.;
input cat1 $ cat2 $ pct_row;
datalines;
TypeA TypeA 0.55
TypeA TypeB 0.55
TypeB TypeA 0.55
TypeB TypeB 0.60
;
run;

proc sgrender data=bar template=test;
run;

 

DataLattice.png

View solution in original post

2 REPLIES 2
Jay54
Meteorite | Level 14

Sometimes an inline annotation (DRAWTEXT) is what you need.

 

proc template;
  define statgraph test;
    begingraph;
      layout datalattice rowvar=cat1 / pad=(left=5pct)
                                 row2axisopts=(label='Cat 2 Description')
                                headerlabeldisplay=value headerlabellocation=outside rowheaders=left;
       drawtext "Cat 1 Description" / x=0 y=55 anchor=top rotate=90 width=50 drawspace=layoutpercent;

       layout prototype;
         barchart x=cat2 y=pct_row / orient=horizontal yaxis=y2;
      endlayout;
    endlayout;
  endgraph;
end;

 

data bar;
format pct_row percent.;
input cat1 $ cat2 $ pct_row;
datalines;
TypeA TypeA 0.55
TypeA TypeB 0.55
TypeB TypeA 0.55
TypeB TypeB 0.60
;
run;

proc sgrender data=bar template=test;
run;

 

DataLattice.png

mbg
Calcite | Level 5 mbg
Calcite | Level 5

Thanks Sanjay, that does the trick.

 

DRAWTEXT was indeed the missing link. I was trying to do it using ENTRY and not getting anywhere.

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
  • 2 replies
  • 1358 views
  • 0 likes
  • 2 in conversation