Data visualization with SAS programming

How do I make PCA dots be identified?

Reply
New Contributor
Posts: 2

How do I make PCA dots be identified?

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 

PROC Star
Posts: 653

Re: How do I make PCA dots be identified?

What does your code look like?

New Contributor
Posts: 2

Re: How do I make PCA dots be identified?

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.
SAS Super FREQ
Posts: 3,623

Re: How do I make PCA dots be identified?

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

Ask a Question
Discussion stats
  • 3 replies
  • 136 views
  • 0 likes
  • 3 in conversation