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

Hi there,

I was wondering how you specify a different title for each plot when using ODS layout gridded with proc sgplot?

 

I realize I can manually type in a different title, but I'd like an automatic way of doing it since I have many plots to display together. As you see in the main graph below, I have, for example, variablename=Dummy Var1 when I simply want Dummy Var1.

 

I'm using SAS 9.4, running on EG 7.15. The graph and relevant code are below.

 

Thanks!!!

SAS Results Graph.PNG

 

data AllMVariables;
	length variablename $25 measure $10;
	infile datalines dlm=' ' dsd;
	input variablename $ measure $ macvalue measurey;
	datalines;
"Dummy Var1" "Boston" 1.62 0
"Dummy Var1" "Boston" 5.60 0
"Dummy Var1" "Denver" 1.70 10
"Dummy Var1" "Denver" 3.56 10
"Dummy Var1" "Denver" 2.16 20
"Dummy Var1" "Denver" 2.13 20
"Dummy Var1" "Denver" 2.12 20
"Dummy Var1" "Denver" 2.12 20
"Dummy Var1" "Denver" 2.09 20
"Dummy Var1" "Denver" 2.05 20
"Dummy Var1" "Denver" 2.02 20
"Dummy Var2 Lag4" "Boston" 1.62 0
"Dummy Var2 Lag4" "Boston" 5.60 0
"Dummy Var2 Lag4" "Denver" 1.80 10
"Dummy Var3 Lag4" "Denver" 3.56 10
"Dummy Var3 Lag4" "Denver" 2.05 20
"Dummy Var3 Lag4" "Denver" 3.02 20
"Dummy Var4" "Boston" 1.62 0
"Dummy Var4" "Boston" 5.60 0
"Dummy Var4" "Denver" 1.70 10
"Dummy Var4" "Denver" 2.05 20
"Dummy Var4" "Denver" 2.02 20
"Dummy Var5" "Boston" 1.62 0
"Dummy Var5" "Boston" 5.60 0
"Dummy Var5" "Denver" 1.80 10
"Dummy Var5" "Denver" 3.56 10
"Dummy Var5" "Denver" 3.55 10
"Dummy Var5" "Denver" 2.09 20
"Dummy Var5" "Denver" 2.05 20
"Dummy Var5" "Denver" 2.02 20
;
run;

goptions htitle=9pct htext=6pct;
options nodate nonumber;
title1 "Main Graph Title";
ods graphics / width=2.37in height=1.02in;
ods layout gridded columns=3 rows=4 advance=bygroup COLUMN_GUTTER=3pt style=[backgroundcolor=Gray fontfamily= "Calibri" fontweight = bold fontsize=8pt color=black];
ods region;

	/*for each variablename */
	proc sgplot data=AllMVariables uniform=group noautolegend;
		by variablename;
		scatter x=macvalue y=measurey / group=measure grouporder=reversedata;

		/* label variablename='';*/
		/* x2axis display=(noline noticks novalues) label=quote(variablename);*/
		xaxis display=none;
		yaxis display=none;
	run;

ods layout end;
ods powerpoint close;
quit;
;

 

1 ACCEPTED SOLUTION

Accepted Solutions
happy_mouth
Obsidian | Level 7

Hi Paige,

 

I ended up talking to tech support.

 

They suggested that I (in SAS EG) deselect all the Result Formats from Tools->Options except PowerPoint, and set the Graph Format to PNG.

 

Your solution worked then!

 

thanks,

Dave

View solution in original post

5 REPLIES 5
happy_mouth
Obsidian | Level 7

Hi Paige,

 

Thanks for your reply. I should have been more specific in my request. I need the title for each graph to be unique. For instance, the tile for graph 1 should be Dummy Var1, the title for graph 2 should be Dummy Var2, and so on. With your method I get the title for the first graph as I wanted, but I get no title at all for each of the other graphs. (See below, for graph, and for the code where I added title "#BYVAL1"😉

 )

 

I was hoping to do this without having to type in each title separately.

 

Thanks again.

 

SAS Results Graph2.PNG

 

options nobyline;

	/*for each variablename */
	proc sgplot data=AllMVariables uniform=group noautolegend;
		by variablename;
		scatter x=macvalue y=measurey / group=measure grouporder=reversedata;
 		title "#BYVAL1";
		xaxis display=none;
		yaxis display=none;
	run;
PaigeMiller
Diamond | Level 26

It should work, but I have never used ODS LAYOUT GRIDDED in this case, so I don't know why it didn't work. Does it work if, as an experiment, you eliminate ODS LAYOUT GRIDDED?

--
Paige Miller
happy_mouth
Obsidian | Level 7

Yes, the titling does work if I comment out ODS LAYOUT GRIDDED.

 

But unfortunately, I then get only one plot per page, rather than all of the plots in a grid on the same page.

 

Thanks.

happy_mouth
Obsidian | Level 7

Hi Paige,

 

I ended up talking to tech support.

 

They suggested that I (in SAS EG) deselect all the Result Formats from Tools->Options except PowerPoint, and set the Graph Format to PNG.

 

Your solution worked then!

 

thanks,

Dave

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 1013 views
  • 1 like
  • 2 in conversation