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

Hi everyone, maybe it is a dumb question for you guys expert on this.

 

I have the following code but i would like to have the % values to have the same color for each respective line color.

In other words, the three % values on top of the red line to be also red, the values of the blue dashed line to be blue, and the respective green line values to be also green.

 

What am I missing?

 

ods graphics on / ATTRPRIORITY=NONE;
proc sgplot data=m3 noborder ;
scatter x=PRRSV2 y=Mu3 / group=PRRSresult1
yerrorupper=upperMux2 yerrorlower=LowerMux2 group=PRRSresult1 groupdisplay=cluster clusterwidth=0.05 ;
series x=PRRSV2 y=Mu3 / group=PRRSresult1 GROUPLC=PRRSresult1 GROUPLP=PRRSresult1 GROUPMC=PRRSresult1
DATALABEL=Mu4 lineattrs=(thickness=3px) DATALABELATTRS=(Color=black Family="Times" Size=10 Style=normal Weight=bold) name="series" ;
styleattrs datacontrastcolors=(VIYG VIGB VIPK) datalinepatterns=(solid dash 16) DATASYMBOLS=(circleFilled SquareFilled) ;
xaxis VALUEATTRS=(Color=black Family=times Size=12
Style=normal Weight=bold) label='Dx Code - PRRS' labelattrs=(size = 14) type=discrete;
yaxis VALUEATTRS=(Color=black Family=times Size=12
Style=normal Weight=bold)label='W2F mortality (%)' labelattrs=(size = 14);
keylegend "series" / titleattrs=(weight=bold size = 10) location=inside position=topleft across=1 title= "Sow farm PRRS status";
title "(Sow farm PRRS status) * (Dx Code - PRRS)";
run;

 

 

edison83_0-1665087298995.png

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
/*or using TEXT statement instead of markerchar= */
proc sgplot data=sashelp.class nocycleattrs;
scatter x=age y=height/ group=sex;
text x=age y=height text=name/strip contributeoffsets=none group=sex position=ne ; /*position=nw|se|sw|top|bottom*/
run;

Ksharp_0-1665233315046.png

 

 

/*or make a new variable to relocate "markerchar="*/
data class;
 set sashelp.class;
 new_height=height+1;
run;
proc sgplot data=class nocycleattrs;
scatter x=age y=height/ group=sex;
scatter x=age y=new_height /markerchar=name group=sex ; 
run;

View solution in original post

4 REPLIES 4
Ksharp
Super User
Remove
"DATALABEL=Mu4"
and add one more SCATTER
" scatter x=PRRSV2 y=Mu3 /markerchar=Mu4 discreteoffset=0.5 ; "
edison83
Obsidian | Level 7

Thanks a lot, that worked just fine.

 

Can you help me with one last question. I am struggling to find a statement now for changing the location of the labels using the "markerchar="

 

See below how they are being plotted on the chart now.

 

edison83_0-1665157270513.png

 

 

Ksharp
Super User
/*or using TEXT statement instead of markerchar= */
proc sgplot data=sashelp.class nocycleattrs;
scatter x=age y=height/ group=sex;
text x=age y=height text=name/strip contributeoffsets=none group=sex position=ne ; /*position=nw|se|sw|top|bottom*/
run;

Ksharp_0-1665233315046.png

 

 

/*or make a new variable to relocate "markerchar="*/
data class;
 set sashelp.class;
 new_height=height+1;
run;
proc sgplot data=class nocycleattrs;
scatter x=age y=height/ group=sex;
scatter x=age y=new_height /markerchar=name group=sex ; 
run;
edison83
Obsidian | Level 7
Thanks, that worked just fine!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2069 views
  • 0 likes
  • 2 in conversation