BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
dsam
Fluorite | Level 6
I am using a code below: and attached sample data. I am getting image as below. I want to show green color for Responders and red color for Non responders .
 
dsam_0-1702886404033.png

 

 
%macro new (var1=,var2=, var3=,var4=);
data v1v2&var3&var4/*(drop=sno)*/;
set final1;
 
 
if responder= 'Responder' then rsp=1;
else if responder='Non-Responder' then rsp=2;
 
if sno=1 then study= 'Harmony';
else if sno=2 then study='Encore';
 
where actarmcd= &var1 and paramcd= &var2;
 
proc sort; by sno sub newn /*avisit responder*/;
run;
 
data myattrmap;
set v1v2&var3&var4;
retain id "myid";
value= responder;
if responder eq "Responder" then linecolor= "green";
else linecolor= "red";
run;
 
 
/*data myattrmap;
/*input ID $ value $ markercolor $ markersymbol $;*/
/*set v1v2&var3&var4
 
myID ="myID";
value= sub;
if responder= 'Responder' then linecolor= 'Green';
else if responder= 'Non-Responder' then linecolor= 'Red';
run;*/
 
proc format;
value avis
 
0= 'HBase'
1= 'HWk20'
2= 'HWk38';
 
value stu
 
1= 'Harmony'
2='Encore';
run;
 
 
 
proc sgpanel data= v1v2&var3&var4 noautolegend dattrmap= myattrmap;
 
format /*newn avis.*/ sno stu.;
title "Individual Biomarker panel Plot for Qualifying subjects with &var1 and &var2";
panelby sno/ spacing=5 novarname;
scatter x=newv y=aval//*markers markerattrs= (symbol=circlefilled size=9)*/ group=sub /*curvelabel*/ /*attrid= myid */;
series x=newv y=aval/ group= sub attrid=myid;
rowaxis label="&var2";
colaxis label="Analysis Visit";
/*highlow x=newv high =hp75 low=hp25//*lineattrs=(thickness=2)*/ /*group=res;*/
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You want this ?

 

libname x v9 'c:\temp\';
 
proc format;
value avis
0= 'HBase'
1= 'HWk20'
2= 'HWk38';
 
value stu
1='Harmony'
2='Encore';
run;
 
 
 
proc sgpanel data= x.Sampledata1 noautolegend ;
styleattrs datacontrastcolors=(green red) ;
format  sno stu.;
title "Individual Biomarker panel Plot for Qualifying subjects with &var1 and &var2";
panelby sno/ spacing=5 novarname;
series x=newv y=aval/ markers group= sub  markerattrs=(symbol=circlefilled)  lineattrs=(pattern=solid)   grouplc=sno groupmc=sno ;  /*<----*/
rowaxis label="&var2";
colaxis label="Analysis Visit";
run;

Ksharp_0-1702888166729.png

 

View solution in original post

5 REPLIES 5
Ksharp
Super User

You want this ?

 

libname x v9 'c:\temp\';
 
proc format;
value avis
0= 'HBase'
1= 'HWk20'
2= 'HWk38';
 
value stu
1='Harmony'
2='Encore';
run;
 
 
 
proc sgpanel data= x.Sampledata1 noautolegend ;
styleattrs datacontrastcolors=(green red) ;
format  sno stu.;
title "Individual Biomarker panel Plot for Qualifying subjects with &var1 and &var2";
panelby sno/ spacing=5 novarname;
series x=newv y=aval/ markers group= sub  markerattrs=(symbol=circlefilled)  lineattrs=(pattern=solid)   grouplc=sno groupmc=sno ;  /*<----*/
rowaxis label="&var2";
colaxis label="Analysis Visit";
run;

Ksharp_0-1702888166729.png

 

dsam
Fluorite | Level 6
thank you so much ! Yes, this is what I wanted. Is there a way to show the legend showing green is responder and red is non responder?
dsam
Fluorite | Level 6
Actually, Sorry I realized this is only coloring per panel. I have to show green and red both colors in each panel depending on their responder status. so each panel will have both colors depending on what each subject's responder status is. can you please help with that?
Ksharp
Super User

OK. How about this one ?

 

libname x v9 'c:\temp\';
 
proc format;
value avis
0= 'HBase'
1= 'HWk20'
2= 'HWk38';
 
value stu
1='Harmony'
2='Encore';
run;
 
 
 
proc sgpanel data= x.Sampledata1  ;
styleattrs datacontrastcolors=(red green) ;
format  sno stu.;
title "Individual Biomarker panel Plot for Qualifying subjects with &var1 and &var2";
panelby sno/ spacing=5 novarname;
series x=newv y=aval/ markers group= sub  markerattrs=(symbol=circlefilled)  lineattrs=(pattern=solid)   grouplc=responder groupmc=responder ;  
rowaxis label="&var2";
colaxis label="Analysis Visit";

legenditem name='a' type=markerline/markerattrs=(symbol=circlefilled color=red) lineattrs=(color=red) lable='Non-Responder';
legenditem name='b' type=markerline/markerattrs=(symbol=circlefilled color=green) lineattrs=(color=green) label='Responder';
keylegend 'a' 'b';
run;

Ksharp_0-1702889405053.png

 

dsam
Fluorite | Level 6
Yes, Perfect! Thank you so much! I really appreciate your quick response and help with this!

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
  • 1047 views
  • 1 like
  • 2 in conversation