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;
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.
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;
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;
On the SCATTERPLOT, set INCLUDEMISSINGGROUP=false.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.