BookmarkSubscribeRSS Feed
Manvel
Obsidian | Level 7

Hello,

 

I have the Scatterplot which have regression lines. Is there any way to keep some of the Symbol invisible. The reg line need to be populated for all "Group" variable but some of the symbols need to be invisible.

proc sgplot data=fina noautolegend ;
    by avisitn avisit;    
    ods output sgplot=sg; 
   
  scatter X=X_ Y=Y_ / group = trt01p groupdisplay=cluster name='s' markerattrs=(size=8px);  
  reg X=X_ Y=Y_/ group = trt01p name='r' lineattrs=(thickness=2px);  

  discretelegend "s" / title="Treatment:" location=outside position=bottom linelength=1.6cm across=5 down=3;
  discretelegend "r" / title="Treatment:" location=outside position=bottom linelength=1.6cm across=5 down=3;

  yaxis  min=&min1 max=&max1 valueattrs=(size=10) valueshint label="YYYY" labelattrs=(size=10);   
  xaxis  min=&min2 max=&max2 valueattrs=(size=10) valueshint label="XXXX" labelattrs=(size=10); 
run;
4 REPLIES 4
ballardw
Super User

A DATTRMAP= data set will let you set properties for lines and markers based on the value of the group variable(s). So you could set  MARKERTRANSPARENCY=1 for some, that should render the selected markers invisible (actually 100% transparent).

 

 

The more control that you want over the group text, lines, colors, markers the more likely that you want a DATTRMAP data set.

 

djrisks
Barite | Level 11

Hi, you could set the symbol size to be 0px. However, all the symbols would be invisible.

 

You could also just create 2 new variables (such as X2_ and Y2_) that you would use in the SCATTER statement, and these two new variable could just have the points that you want plotted.

 

proc sgplot data=fina noautolegend ;
    by avisitn avisit;    
    ods output sgplot=sg; 
   
  scatter X=X2_ Y=Y2_ / group = trt01p groupdisplay=cluster name='s' markerattrs=(size=8px);  
  reg X=X_ Y=Y_/ group = trt01p name='r' lineattrs=(thickness=2px);  

  discretelegend "s" / title="Treatment:" location=outside position=bottom linelength=1.6cm across=5 down=3;
  discretelegend "r" / title="Treatment:" location=outside position=bottom linelength=1.6cm across=5 down=3;

  yaxis  min=&min1 max=&max1 valueattrs=(size=10) valueshint label="YYYY" labelattrs=(size=10);   
  xaxis  min=&min2 max=&max2 valueattrs=(size=10) valueshint label="XXXX" labelattrs=(size=10); 
run;

 

Manvel
Obsidian | Level 7

Thanks for valuable information that is work but now I have minor issue in my Legend part. Please advice how I can remove this symbol from Legend part(Picture below). For "E" and "F" I need to have reg lines but the symbols need to be missing or invisible.

proc sgplot data=final(where=(AVISITN =&vis.))noautolegend ;
    by avisitn avisit;    
    ods output sgplot=sg; 
   
  Title7 justify=left "ZZZZ";

  scatter X=X_ Y=Y_ / group = trt01p_ groupdisplay=cluster name='s' markerattrs=(size=8px);  
  reg X=X Y=Y / group = trt01p name='r' lineattrs=(thickness=2px) markerattrs=(size=0px);  

  discretelegend "s" / title="Treatment:" location=outside position=bottom linelength=1.4cm across=5 down=3;
  discretelegend "r" / title="Treatment:" location=outside position=bottom linelength=1.6cm across=5 down=3;

  yaxis  min=&min1 max=&max1 valueattrs=(size=10) valueshint label= "XXXX" labelattrs=(size=10);   
  xaxis  min=&min2 max=&max2  valueattrs=(size=10) valueshint label="YYYY" labelattrs=(size=10); 

run;

 

 

Manvel_0-1687434133005.png

 

DanH_sas
SAS Super FREQ

On the SCATTERPLOT, set INCLUDEMISSINGGROUP=false.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 851 views
  • 6 likes
  • 4 in conversation