BookmarkSubscribeRSS Feed
_user
Calcite | Level 5

 

 Hello All, 

 

My Sgplot code looks like below and the Legend that appearing "Name = a " ( Treatment arms )  at the end of Vbox . Along with that I also want the Scatter Plot colors in the Legend , if I try to have Name = "Scat"  and use it in Keylegend TRT01A is coming up as it is Grouping variable . How to get the Scatter Plot color into the Legend ?

 

Example  along with TRT arm ,  red color = &var2. , Green color = &var1 something like this 

 

%macro box_j (yvar , var1,var2 , out , Vis , label  );

     /*--Grouped Box with Stat Table Scatter--*/;

 

ods graphics / reset attrpriority=color width=5in height=3in imagename= "&out._&vis._Box_jitter" ;

Title "Boxplot ";

 

proc sgplot data=mergedGroup ;

label value='N';   format value 5.2;

yaxis values = (-6 to 6 by 2);

vbox &yvar. / category= &var2. group=TRT01A nooutliers  nofill grouporder=ascending name='a';

 

scatter x=&var2. y=&yvar.   / group=TRT01A groupdisplay=cluster

        grouporder=ascending jitter

        markerattrs=(symbol=circlefilled size=5  color = red  )

        transparency=0.5 clusterwidth=0.5  *Name = "Scat" * ; <-- I want  &var2 color in the Legend 

 

scatter x=&var1.  y=&yvar.  / group=TRT01A groupdisplay=cluster

      grouporder=ascending jitter

      markerattrs=(symbol=square size=5   color = green )

      transparency=0.65 clusterwidth=1; <-- I want  &var1 color in the Legend 

 

xaxistable STD / x=cat class=grp classdisplay=cluster colorgroup=grp location=inside classorder=ascending label = "&var2.";

xaxis display=(nolabel);

keylegend 'a' / linelength=24;

*keylegend 'Scat' / linelength=24;

run;

 

  QUIT;

%MEND box_j;

 

 

%box_j(lV4 , TRT,FR , log  , V4 ,%str( V4 ) );

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 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
  • 0 replies
  • 891 views
  • 0 likes
  • 1 in conversation