Programming the statistical procedures from SAS

Can Cluster analysis deal only with one variable?

Reply
Contributor
Posts: 25

Can Cluster analysis deal only with one variable?

Hi!

I have a data set with two variables,one is the ID,the other is the amount.Can proc cluster or porc fastclus deal only with the amount?

And what is the difference between quantile and cluster?

Maybe I am too careful,but I have to make it clear.

Thanks in advance!

Respected Advisor
Posts: 4,742

Re: Can Cluster analysis deal only with one variable?

Yes, you can do clustering on a single variable. Suppose you know that there are two groups in your data and want to separate them automatically, you could use clustering to do that. Run the following example:

/* Generate example data with 2 clusters in variable x */

data test;
do x = 1,2,3,4,5,12,13,14;
id = put(x,2.);
output;
end;
run;

/* Form all clusters */

proc cluster data=test outtree=tree method=centroid noprint;
var x;
id id;
run;

/* Isolate top 2 clusters */

proc tree data=tree out=clusters nclusters=2 noprint;

run;

/* Get quantiles */

proc rank data=test fraction out=quantiles;
var x;
ranks quantile;
run;

/* Assemble clusters and quantiles */

proc sql;
select Q.id, Q.x, Q.quantile label="Quantile", C.cluster
from clusters as C inner join quantiles as Q on C._NAME_=Q.id
order by cluster, x;
quit;

Observations are assigned to the proper cluster. The quantiles are just like rescaled ranks.

PG

PG
Ask a Question
Discussion stats
  • 1 reply
  • 2655 views
  • 3 likes
  • 2 in conversation