BookmarkSubscribeRSS Feed
fd2010
Calcite | Level 5
In the following code, I try to make the symbols be black for both groups. But it doesn't work and I still get colored lines for each group. What should I do?

Thanks,
fd2010
_______________________________________
ods rtf file = "&out..rtf" style=uslandscape;
ods graphics on;
ods noptitle;
ods select survival;
proc lifetest data=failkm plots=(s);
time day*censor(1);
survival plots=(survival);
strata trtn;
symbol1 c=black l=12;
symbol2 c=black l=1;
format trtn trt.;
run;

ods graphics off;
ods rtf close;
3 REPLIES 3
DanH_sas
SAS Super FREQ
Hey,

It appears you have a custom style called "uslandscape". You can modify this style to make the graph output black and white. Another alternative to use the "journal2" style.

Thanks!
Dan
fd2010
Calcite | Level 5
Thanks for your suggestion. I tried style=journal2 and the plots still come out in color. It appears that the proc lifetest plot is using a template as identified by turning on 'ods trace on'. It is not apparent how one can modify this ProductLimit template to change the colors of the plot lines....

-------------
Name: Survival
Label: Product-Limit Survival
Template: Stat.Lifetest.Graphics.ProductLimit
Path: Lifetest.Survival
-------------
Cynthia_sas
SAS Super FREQ
Hi:
The template that PROC LIFETEST is using is the Graph template that you see when you run ODS TRACE. The Graph templates should be coded to work with the style template that is active in your code (STYLE= option) and that means the colors from the style template will/should be used for the graph image. So when you use style=journal or style=journal2 (instead of your custom style), you should get black lines.

Do remember that with ODS RTF, when you look at the output, you must CLOSE the RTF file every time or else when you re-run the job, you will see error messages in the log that say something like:
[pre]
ERROR: File is in use, <path>\filename.rtf.
ERROR: Fatal ODS error has occurred. Unable to continue
processing this output destination.
[/pre]

So, if your original RTF file was open when you ran the STYLE=JOURNAL step, you might not have seen any changes if you did not close the file before you reran the job. The other workaround, of course, is to change the file name between runs.

The behavior you observe is very odd. When I run this PROC LIFETEST whether I use style=journal or style=journal2 -- my lines are still black. (This may not be the best LIFETEST example. I wasn't exactly sure which plot you wanted, but I got black lines on my SurvivalPlot for each of my Strata lines -- I had 3 levels of CHOL_STATUS.)
[pre]
ods rtf file='c:\temp\journal.rtf' style=journal;
ods graphics on;
ods noptitle;

ods select SurvivalPlot;
proc lifetest data=sashelp.heart plots=(s);
title 'Using Changed Style Template';
time ageatdeath*systolic(150);
strata chol_status;
run;

ods graphics off;
ods _all_ close;

[/pre]

The style elements used for the colors of lines are the "GCDATAn" style attributes. If all you wanted to do was change the colors of the lines, you would only need to change the GCDATAn colors in the GraphColors style element. In the example below, I have changed GCDATA1, GCDATA2 and GCDATA3 to be very noticeable colors, so you can observe which color is used for which line. If you want to change the colors AND the line styles, then you would need to modify the template only a bit more to change the GraphData1, GraphData2 and GraphData3 style elements. For the 3 style attributes, I also change the line style in the template below. (You could, of course, change the colors all to black instead of my purple, cyan and black.)

Note that I took the SYMBOL statements out of the LIFETEST code -- template-based graphics are not impacted by GOPTIONS, AXIS or SYMBOL statements -- so if you are using ODS GRAPHICS, those statements will be ignored.

cynthia

[pre]
proc template;
define style difflines;
parent=styles.rtf;
class GraphColors /
'gcdata12' = cxF9DA04
'gcdata11' = cxB38EF3
'gcdata10' = cx47A82A
'gcdata9' = cxD17800
'gcdata8' = cxB26084
'gcdata6' = cx7F8E1F
'gcdata7' = cx2597FA
'gcdata4' = cx543005
'gcdata5' = cx9D3CDB
'gcdata3' = black
'gcdata2' = cyan
'gcdata1' = purple;
class GraphData1 /
markersymbol = "circle"
linestyle = 4
contrastcolor = GraphColors('gcdata1')
color = GraphColors('gdata1');
class GraphData2 /
markersymbol = "plus"
linestyle = 2
contrastcolor = GraphColors('gcdata2')
color = GraphColors('gdata2');
class GraphData3 /
markersymbol = "X"
linestyle = 8
contrastcolor = GraphColors('gcdata3')
color = GraphColors('gdata3');
end;
run;

options orientation=landscape;
ods rtf file = "c:\temp\chglines.rtf" style=difflines;

ods graphics on;
ods noptitle;

ods select SurvivalPlot;
proc lifetest data=sashelp.heart plots=(s);
title 'Using Changed Style Template';
time ageatdeath*systolic(150);
strata chol_status;
run;

ods graphics off;
ods _all_ close;
[/pre]

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 4610 views
  • 0 likes
  • 3 in conversation