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

Hello all,

 

I am using EG 9.4_M6 to produce plots with a discrete attribute map. The plots are displayed on screen correctly with the grouping variable values each having the defined line color and style (solid).

 

However, the images that are saved via ODS are slightly different. The plots saved as PNG files have the correct line colors for the grouping variable values but the line style changes from solid for the first group value to dashed for the remaining 10 group values.

 

I figured out that if I include ATTRPRIORITY=COLOR option on the ODS GRAPHICS line that the saved output is the same as the on-screen output - both the on-screen and saved plots have the correct line colors and styles.

 

Why does the on-screen plot display correctly with the below code, but the saved plots require the additional ATTRPRIORITY option to match the on-screen output?

 

Here is my graphics code (without the ATTRPRIORITY option):

 

ods listing gpath='\\Figures' image_DPI=300;
ods graphics / reset height=6.5in imagename="Figure101" imagefmt=PNG ;
Footnote justify=left height=1.2 font="Times New Roman" "Figure 1.1";

proc sgplot data=Rates noborder
			dattrmap=AttMap;

	series x=Year y=Rate /
	Group=Type
	Attrid=Type
	smoothconnect
	lineattrs=(thickness=&THICK)
	name="EventRate";

	keylegend "EventRate"  /
	Title="" NOBORDER;
run;

Thanks for reading!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You don't show the DATTRMAP data set contents. Any style element you do not set in the data set will default to the current active style. If you didn't specify line type then the different styles come into effect.

 

If by screen display you mean the results window in SAS that is HTML output. I think the default style used by that is HTMLBLUE but you may have a different choice and the Listing destination defaults to the LISTING style. One of the main differences between the two, at least in my install is HTMLBLUE default line types are solid and Listing uses dashed lines and the two use different marker types.

You may be getting close to the same appearance if the default styles are similar for other items.

 

Moral of the story: specify the ods STYLE you want to make sure that the base style is what you want. Also some options set in ODS Graphics can persist even across SAS sessions. So you may want to RESET them before starting to make sure to have a consistent starting place.

 

Without data I can't say why ATTRPRIORITY is affecting things to get what you want for sure. BUT graph style elements Graphdata1-GraphDataN may have there own Attrpriority settings and you overrode them with the graphics option.

 

Maybe on way it to consider running a modified version of your code that creates multiple output files.

 

ods rtf file="path\folder\file.rtf";
ods pdf file="path\folder\file.pdf";

ods listing gpath='\\Figures' image_DPI=300;
ods graphics / reset height=6.5in imagename="Figure101" imagefmt=PNG ;
Footnote justify=left height=1.2 font="Times New Roman" "Figure 1.1";

proc sgplot data=Rates noborder
			dattrmap=AttMap;

	series x=Year y=Rate /
	Group=Type
	Attrid=Type
	smoothconnect
	lineattrs=(thickness=&THICK)
	name="EventRate";

	keylegend "EventRate"  /
	Title="" NOBORDER;
run;

ods pdf close;
ods rtf close;

and compare the PDF and RTF file appearance to your listing output.

 

Each ODS destination has an output style associated with it by default. PDF and RTF use quite different ones though I think the text elements may show more.

 

 

If this is the underlying cause you may be able to address it by specifying the STYLE= option an and ODS destination statement and see. Results will generally be a bit closer but might run into specific issues such as DPI settings.

 

View solution in original post

2 REPLIES 2
ballardw
Super User

You don't show the DATTRMAP data set contents. Any style element you do not set in the data set will default to the current active style. If you didn't specify line type then the different styles come into effect.

 

If by screen display you mean the results window in SAS that is HTML output. I think the default style used by that is HTMLBLUE but you may have a different choice and the Listing destination defaults to the LISTING style. One of the main differences between the two, at least in my install is HTMLBLUE default line types are solid and Listing uses dashed lines and the two use different marker types.

You may be getting close to the same appearance if the default styles are similar for other items.

 

Moral of the story: specify the ods STYLE you want to make sure that the base style is what you want. Also some options set in ODS Graphics can persist even across SAS sessions. So you may want to RESET them before starting to make sure to have a consistent starting place.

 

Without data I can't say why ATTRPRIORITY is affecting things to get what you want for sure. BUT graph style elements Graphdata1-GraphDataN may have there own Attrpriority settings and you overrode them with the graphics option.

 

Maybe on way it to consider running a modified version of your code that creates multiple output files.

 

ods rtf file="path\folder\file.rtf";
ods pdf file="path\folder\file.pdf";

ods listing gpath='\\Figures' image_DPI=300;
ods graphics / reset height=6.5in imagename="Figure101" imagefmt=PNG ;
Footnote justify=left height=1.2 font="Times New Roman" "Figure 1.1";

proc sgplot data=Rates noborder
			dattrmap=AttMap;

	series x=Year y=Rate /
	Group=Type
	Attrid=Type
	smoothconnect
	lineattrs=(thickness=&THICK)
	name="EventRate";

	keylegend "EventRate"  /
	Title="" NOBORDER;
run;

ods pdf close;
ods rtf close;

and compare the PDF and RTF file appearance to your listing output.

 

Each ODS destination has an output style associated with it by default. PDF and RTF use quite different ones though I think the text elements may show more.

 

 

If this is the underlying cause you may be able to address it by specifying the STYLE= option an and ODS destination statement and see. Results will generally be a bit closer but might run into specific issues such as DPI settings.

 

samp945
Obsidian | Level 7

Thank you! Your advice solved the problem for me.

 

I used the instructions in this blog post to semi-automatically create an attribute map with the ID variable values set to GraphData1-GraphDataN for MarkerStyle, LineStyle, and TextStyle.

 

As you pointed out, the problem was that the HTML output uses a different default style (htmlblue) than the LISTING output (listing). This caused the on-screen HTML output to show solid lines but the PNG files created with the default LISTING style to show dashed lines.

 

I specified the ODS LISTING STYLE as htmlblue and the problem is fixed!

 

ods listing style=htmlblue gpath='\\Figures' image_DPI=300;

Thanks again!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1000 views
  • 2 likes
  • 2 in conversation