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;

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
  • 5 replies
  • 2349 views
  • 1 like
  • 4 in conversation