BookmarkSubscribeRSS Feed
JeffMeyers
Barite | Level 11

I recently began work with a new company that uses Enterprise Guide which my previous employer did not have for me to test on.  I have several macros that output tables specifically formatted to look the same in all destinations (RTF, Excel, PDF, HTML, etc.), but the results viewer in Enterprise Guide isn't following the style modifications like the other destinations.  EG is using ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR as the destination.  Here is some example code:

ods rtf file='test.rtf';
ods escapechar='^';
proc report data=sashelp.class nowd split='~' style(header)={vjust=bottom};
	columns name sex age height weight;

	define name / display 'Name^{super 1}' style={cellwidth=1.5in};
	define sex / display 'Test~Sex';
	compute sex ;
		if sex='F' then call define('name','style/merge','style={fontweight=bold}');
		else call define('name','style/merge','style={leftmargin=0.12in}');
	endcomp;
	compute after;
		line @1 '^{super 1}This Is A Test Footnote';
		endcomp;
run;
ods rtf close;

When I look at the RTF file I get the following:

JeffMeyers_0-1652213828171.png

However when I look at the same table output in the EG results window I get the following:

JeffMeyers_1-1652213868231.png

I can't seem to fix the following issues:

  1. I can't get text to indent.  I have tried using the INDENT style element as well as the LEFTMARGIN style element and both are ignored
  2. When using the escape character to superscript a text it seems to delete all of the spaces in the rest of the text and ignores things like vertical justification (see footnote and first column header vs the rest)
  3. When I try changing to a new style with ODS tagsets.sasreport13(ID=EGSR) style=SomeNewStyle; it ignores the new style unless I close the tagsets and start a new one with the style I want.  Is there a way to make it change to the style that I want without closing/reopening the destination?

I don't think the company focuses too much on what the results look like in the EG results window, but I'm just curious about figuring out what is going on.

7 REPLIES 7
Tom
Super User Tom
Super User

What version of Enterprise Guide are you using?
What version of SAS are you using to run the SAS code?

JeffMeyers
Barite | Level 11
Enterprise version 7.12 HF7
SAS version 9.4M3
ChrisHemedinger
Community Manager

Later versions of SAS Enterprise Guide moved away from SAS Report (ODS tagsets.sasreport13) format as the default, and instead use HTML5. This responds to style updates like you seem to be looking for. I would not recommend SAS Report unless you are directly sharing these results with other SAS applications that can read it (SAS Add-In for Microsoft Office, for example).

 

If your ultimate deliverable is RTF, then I suggest you enable that in your SAS Enterprise Guide preferences (Tools->Options->Results).

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
JeffMeyers
Barite | Level 11
Thanks Chris,
I tried setting the default to HTML, but I run into the same issue where HTML (not HTML5) doesn't update the style properly in the middle of the ODS tags. It essentially follows whatever style was specified in the first ODS HTML tag. For example, if I close the HTML and start a new one with the style my macro makes the table looks as expected, but when the macro is run within already existing HTML tags it comes out wrong. Is there an option in HTML to force the style to change?
I don't have an option in this version of SAS EG to set HTML5 as the default, just regular HTML. Running in HTML5 in SAS Studio works fine compared to regular HTML.
Ksharp
Super User

Did you try style  asis=on  or  pretext='     ' ?

 

ods rtf file='test.rtf';
ods escapechar='^';
proc report data=sashelp.class nowd split='~' style(header)={vjust=bottom};
	columns name sex age height weight;

	define name / display 'Name^{super 1}' style={cellwidth=1.5in};
	define sex / display 'Test~Sex';
	compute sex ;
		if sex='F' then call define('name','style/merge','style={fontweight=bold}');
		else call define('name','style/merge','style={leftmargin=0.12in asis=on pretext="    "}');
	endcomp;
	compute after;
		line @1 '^{super 1}This Is A Test Footnote';
		endcomp;
run;
ods rtf close;
JeffMeyers
Barite | Level 11
I honestly did not know about the ASIS and PRETEXT options, so I have not tried them. It is a good backup plan if there isn't a better solution. I like indent and leftmargin more because I can specify an exact indent value vs spaces that change with font size, and leftmargin will still indent any wrapped text.
ChrisHemedinger
Community Manager

I'll start with an opinion: chasing a pixel-perfect layout for HTML-based results in a tool like SAS Enterprise Guide -- that's probably more effort than it's worth. Of course SAS programmers who are accustomed to producing output for journals and other research are used to employing all kinds of tricks for RTF and PDF. But HTML is so dependent on browser, user display preferences, styles in CSS, etc. -- you can spend a lot of energy and still not achieve the result you want.

 

That said, in EG and SAS there are multiple factors that contribute to HTML appearance:

  • Style selection in EG preferences (using the CSS stylesheet), and you can see all of the options "previewed" in the Style Manager tool in the Tools menu. (Fun fact: I built that tool in the late 1990s for EG 1.0 and while it has been re-implemented because of technology change, it's pretty much the same as it was.)
  • Style template in ODS, which has the same name as the stylesheet-based thing you see previewed in the Style Manager. See the built-in styles with this program:
    proc template;
       path sashelp.tmplmst;
       list styles;
    run;

You can define new styles with PROC TEMPLATE, and you can use PROC TEMPLATE to build new stylesheets that you can then add to the Style Manager in EG. 

 

You can also edit/create a CSS file with the proper CSS classes, and use PROC TEMPLATE to read that in and create a SAS style template. You can find more doc in the ODS section of SAS documentation.

 

However, if you want to make style changes that everyone in a company can see/use in the same way, then you need to use PROC TEMPLATE to define and add to a central location, update the ODS template search path so it will be found when referenced, and then use EG's Style Manager to add it as an option to the selectable styles ("server-only style").

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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