BookmarkSubscribeRSS Feed
jcvaldoz
Calcite | Level 5

I have been doing PCA in SAS University Edition recently and now, I have got 800 observations plotted on the graph. My problem is that each individual dot could not be distinguised due to the large number of samples that we have. Is there a way for me to make the dots and labels smaller for overlap avoidance? Or, can we fish out which samples we are interested in through gating?

 

 

Thanks 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

What does your code look like?

jcvaldoz
Calcite | Level 5
I just used the preset for princom and just changed the plot to "plot=all". There is nothing much in the code; just the principal component command and the show all plots command.
Rick_SAS
SAS Super FREQ

I'm going to assume that you are most interested in labeling the extreme observations. The easiest way to control the labels is to use the OUT= option on the PROC PRINCOMP statement to write the PC scores to a data set. Then use some distance criterion to identify the extreme observations. You can then create a label variable that is blank for non-extreme observations and non-blank for extreme observations.  

 

The following example uses the data from the Getting Started example in the doc. It creates a new character variable that is non-blank for observations that are more than 2.5 units away from the origin in the coordinates of the first two PCs:

 


%let OutlierDist = 2.5;
data Outliers;
set Crime_Components;
dist = Euclid(Prin1, Prin2);
ObsLabel = ifc(dist > &OutlierDist, State, " ");
run;

proc sgplot data=Outliers;
scatter x=Prin1 y=Prin2 / datalabel=ObsLabel;
run;

j.png

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
  • 3 replies
  • 1048 views
  • 0 likes
  • 3 in conversation