BookmarkSubscribeRSS Feed
js5
Pyrite | Level 9 js5
Pyrite | Level 9

Is there a way of providing a formatted title with obtitle? With normal title statement, I can do the following:

title1 justify=left "foo" justify=center "bar" justify=right "baz";

with obtitle this does not work. Inline formatting does not seem to work either:

obtitle2 \a1\titer#1\SGPanel#1 "~{style [textalign=left]foo} ~{style [textalign=center]bar} ~{style [textalign=right]baz}";

The problem is that the header needs to change depending on what is being displayed, but proc sgpanel does not support by statement, so I do not have a by variable to work with and can only work with where.

4 REPLIES 4
ballardw
Super User

First thing SGPanel does support By group processing, though maybe not in the manner you want.

Example:

Proc sort data=sashelp.class out=classsort;
   by sex age;
run;

proc sgpanel data=classsort;
   by sex;
   panelby age;
   scatter x=height y=weight;
run;

Second, you would likely have to show your entire Proc Document code so we can see the context of your attempt, and possibly provide the Sgpanel code and data to create the graphs as well. Best would be to show what you expect the output to look like.

Just in case: did you remember the Escapechar statement?

Some places inline formatting seems to prefer (*ESC*) instead of an escapechar such as ~ . Not sure if this is one of them.

 


@js5 wrote:

Is there a way of providing a formatted title with obtitle? With normal title statement, I can do the following:

title1 justify=left "foo" justify=center "bar" justify=right "baz";

with obtitle this does not work. Inline formatting does not seem to work either:

obtitle2 \a1\titer#1\SGPanel#1 "~{style [textalign=left]foo} ~{style [textalign=center]bar} ~{style [textalign=right]baz}";

The problem is that the header needs to change depending on what is being displayed, but proc sgpanel does not support by statement, so I do not have a by variable to work with and can only work with where.


 

js5
Pyrite | Level 9 js5
Pyrite | Level 9

Thank you for pointing out that by statement is supported. It was being highlighted in red by Enterprise Guide so I assumed that it is not supported:

Screenshot 2022-10-26 093619.png

I guess I should not trust the syntax highlighting blindly.

I did use ods escapechar. I solved my problem in the meantime by replacing the by statement needed by where and doing a macro loop, and putting the title code inside the macro loop instead of outside.

ballardw
Super User

@js5 wrote:

Thank you for pointing out that by statement is supported. It was being highlighted in red by Enterprise Guide so I assumed that it is not supported:

Screenshot 2022-10-26 093619.png

I guess I should not trust the syntax highlighting blindly.

I did use ods escapechar. I solved my problem in the meantime by replacing the by statement needed by where and doing a macro loop, and putting the title code inside the macro loop instead of outside.


Depends on a number of factors how well syntax highlighting "works". I am surprised about BY but I have had issues with the highlighting not having the options of new procedures work. There is a slim chance that copying code from some sources acquires not-displayed characters that the highlighting finds.

 

Better to test with a small data set and see what the LOG says.

 

js5
Pyrite | Level 9 js5
Pyrite | Level 9

I was able to achieve what I need by using activetitle statement:

title1 justify=left "foo" justify=center "bar" justify=right "baz";

ods document name=work.test(write);

proc report data=sashelp.cars;
	columns Origin Make MSRP;
	define Origin / group;
	define Make / group;
	define MSRP / analysis mean;
run;

ods document close;
title1;
title1 justify=left "one" justify=center "two" justify=right "three";

ods word file="C:\users\&sysuserid.\Work Folders\Desktop\SAS\obtitle\test.docx";

proc document name=work.test(update);
/*	obtitle \Report#1\Report#1\Report#1 "(*ESC*){style [textalign=left]one} (*ESC*){style [textalign=center]two} (*ESC*){style [textalign=right]three}";*/
	replay ^ / activetitle;
run;

ods word close;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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