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;
Thanks!
/*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;
/*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;
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.
/*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;
/*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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.