%let ht = .6; %let C= .1; data macaroni; do i = 1 to 500; a = ranuni(123)*3.14159; id="Green"; Z = cos(A); X=0; Y=sin(A)-&ht; Z = Z + &c*normal(123); X=X+&C*normal(123); Y=Y+&C*normal(123); output; a = ranuni(123)*3.14159; id="Cyan"; X= cos(A); Z = 0; Y = -sin(A)+&ht; Z = Z + &c*normal(123); X=X+&C*normal(123); Y=Y+&C*normal(123); output; X=1; Y = -1; Z=2*(ranuni(123)-.5); id="red"; Z = Z + &c*normal(123); X=X+&C*normal(123); Y=Y+&C*normal(123); output; end; proc g3d data = macaroni; title "Data as Generated"; scatter X*Y=Z/color=id shape="Balloon" size=0.8 noneedle; run; ** Using CLUSTER **; %let method = Single; proc cluster method=&method ccc outtree=tree data=macaroni noprint; var x y z; title "Clustering with the &method Method"; proc print data=tree(obs=10); run; proc tree data=tree height=ncl spaces=1 inc=1 out=outclus ncl=5; * where _ncl_<80; copy x y z; data outclus; set outclus; color="green"; if cluster=1 then color="red"; if cluster=2 then color="black"; if cluster=3 then color="blue"; if cluster=4 then color="cyan"; proc g3d data=outclus; scatter x*y=z/noneedle shape= "balloon" size= .5 color=color; run; /** Using MODECLUS ***; proc modeclus method=1 k=60 out=outmac data=macaroni cascade=3; var x y z; title "Clusters"; proc print data=outmac (obs=10); run; data outmac; set outmac; color="green"; if cluster=1 then color="red"; if cluster=2 then color="black"; if cluster=3 then color="blue"; if cluster=4 then color="cyan"; proc g3d data=outmac; scatter x*y=z/noneedle shape= "balloon" size= .5 color=color; run; * */ ;