BookmarkSubscribeRSS Feed
Forgotthesemicolon
Calcite | Level 5

I'm doing some clustering analysis so I used PROC FACTOR on about 70 variables to first create factors, then ran PROC FASTCLUS on the resulting 15 factors to divide them into clusters. I did this on a sample of 100k records out of over a million.

So now I'm trying to take that clustering as-is and apply it to the entire population of 1mill+. So I have a file of all 1mill+ records and the 70 key variables, and need to apply the same factoring I used on my sample to get the 15 factors for them. Then I need to apply the same clustering I got from the sample to the full population. I don't want to refresh or re-cluster the data, just roll out the existing clustering.

I'm not really sure if SAS has an easy way to do this. I've used the OUTSTAT options in both PROC FACTOR and PROC FASTCLUS to store the factor scores and the cluster centroids. It should be just a matter of applying those to my 1mill+ population dataset. Is there some kind of INSTAT option?

3 REPLIES 3
Reeza
Super User

Start with the Proc Factor replication:

Check out Proc Score that will allow you to replicate this. You may want to test this to ensure you're getting what you expect.

SAS/STAT(R) 9.22 User's Guide

The replication of the Clustering is a question that has been asked on here before so searching will get you the answer, which I think is, it depends on the type of clustering performed and may not be possible for all types of clustering.

Forgotthesemicolon
Calcite | Level 5

Thanks that works great for the factor analysis. On the cluster analysis, I used PROC FASTCLUS which I believe is k-means clustering. I stored the OUTSTAT output which contains all the cluster centroids:

PROC FASTCLUS DATA=FactoredData

  MAXC=16 MAXITER=5 REPLACE=NONE STRICT=5 OUT=FileOut OUTSTAT=StatOut;

  VAR Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8 Factor9 Factor10 Factor11 Factor12 Factor13 Factor14 Factor15;

RUN;

so in theory there's no reason I can't cluster the full population with the same clustering. I just need to know if there's a command and what the syntax is. I could even do it manually if necessary, it's just a Euclidean distance metric. But it'd be a lot neater if there's already a command to do that, like PROC SCORE did for the factor analysis.

Forgotthesemicolon
Calcite | Level 5

Actually never mind, I figured it out in the end. Had to use the INSTAT option in PROC FASTCLUS.

Thanks for all your help!

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
  • 1722 views
  • 4 likes
  • 2 in conversation