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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 791 views
  • 0 likes
  • 3 in conversation