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

Hi, my question is pretty straightfoward. In this particular code I want to show two symbols in the legend. However, I am not sure how to write syntax to show a trianglefilled and starfilled in the legend. The legend is only populating with subjects that i'm plotting but I would like a legend that shows a star and a triangle so I can indicate one is for the first series and the other one is for the second series since it's all on the same graph. This is my code. 

 

proc sgplot data=adef_bleed_part noautolegend dattrmap=MyAttrMap;
styleattrs datasymbols=(trianglefilled starfilled);

series x=astdy y=bleed_ep/
group=subjid markers markerattrs=( size=5 symbol=trianglefilled )
lineattrs=(pattern=5 thickness=.5) NOMISSINGGROUP name="series" attrid=myreg;

series x=stdy y=aval/
group=subjid markers markerattrs=( size=5 symbol=starfilled)
lineattrs=( pattern=1 thickness=2) NOMISSINGGROUP y2axis name="series2" attrid=myreg;

 

xaxis values=(0 to 2200 by 168) label="Study Day" minor;
yaxis values=(0 to 30 by 2) label="Cumulative Number of Bleeding Episodes" labelattrs=(size=7);
y2axis values=(0 to 200000 by 10000) label="Cumulative FIX Consumption (IU)" labelattrs=(size=7);


refline 365/transparency=0.5 label=("Year 1")
labelattrs=(size=4 style=italic weight=bold color=red) lineattrs=(color=red pattern=34) labelloc=outside axis=x;
refline 730/transparency=0.5 label=("Year 2")
labelattrs=(size=4 style=italic weight=bold color=red) lineattrs=(color=red pattern=34) labelloc=outside axis=x;
refline 1095/transparency=0.5 label=("Year 3")
labelattrs=(size=4 style=italic weight=bold color=red) lineattrs=(color=red pattern=34) labelloc=outside axis=x;
refline 1460/transparency=0.5 label=("Year 4")
labelattrs=(size=4 style=italic weight=bold color=red) lineattrs=(color=red pattern=34) labelloc=outside axis=x;
refline 1825/transparency=0.5 label=("Year 5")
labelattrs=(size=4 style=italic weight=bold color=red) lineattrs=(color=red pattern=34) labelloc=outside axis=x;
refline 2190/transparency=0.5 label=("Year 6")
labelattrs=(size=4 style=italic weight=bold color=red) lineattrs=(color=red pattern=34) labelloc=outside axis=x;
keylegend "series" "series2" / exclude=("") sortorder=ascending;
run;
quit;

 

Could you advise what I would need to do? 

1 ACCEPTED SOLUTION

Accepted Solutions
Dregerator
Obsidian | Level 7

Hi, I figured this out using the legenditem condition. 

View solution in original post

2 REPLIES 2
ballardw
Super User

I think to have a chance we need actual data to plot and the Dattrmap data set. You have a lot of options that interact around Group option behavior and we need all the info about your plots.

 

I am not clear if you want just a two-element "legend" (one triangle and one star) in addition to a legend based on your group values or in place of the group values.

Dregerator
Obsidian | Level 7

Hi, I figured this out using the legenditem condition. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1126 views
  • 0 likes
  • 2 in conversation