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

Hello all, 

I am doing a survival curve using proc sgplot and the group statement. I have a total of 8 groups. I need some of the groups to have dotted lines and some of them to have full lines and specify every groups colour. 

How to put it into the following code?

 

proc sgplot data=abc2;
series x=weeks y=SURVIVAL1 /group = exp_event;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

For full control of the attributes try a Discrete Attribute Map .

lone0708
Fluorite | Level 6

Thank you for your answer 🙂
I have tried to make the attribute map (please see attatched photo), but the colours are not at all corresponding. Do i miss something in the code?

 

lone0708_0-1661283909518.png

 

DanH_sas
SAS Super FREQ

The column names in an attributes map are reserved keywords, so they must be spelled as they are expected. In your screenshot, you have spelled the expected "fillcolor" with the alternate "fillcolour" spelling. Also, for a series plot, you should be using "linecolor" instead of "fillcolor".

PaigeMiller
Diamond | Level 26

You can use the STYLEATTRS command in PROC SGPLOT

 

Example

 

styleattrs datacontrastcolors=(orange cyan CXFF0000) 	
    datalinepatterns=(dot solid longdash 26);


Experiment to find what works for you.

--
Paige Miller
DanH_sas
SAS Super FREQ

@PeterClemmensen is correct. You' will want to use an attributes map. Here is a simple example using a SERIES plot below:

 

data attrmap;
retain ID "myid" nocase "true";
input value $ linecolor $ linepattern $;
cards;
F   pink   solid
M   blue   dash
;
run;

proc sgplot data=sashelp.class dattrmap=attrmap;
series x=name y=weight / group=sex attrid=myid;
run;

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
  • 1678 views
  • 1 like
  • 4 in conversation