BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
K_coder
Fluorite | Level 6

I am trying to provide stopping criteria for clustering if K(no of cluster) is less than number of rows.

I have tried using PROC IML, but not getting proper output.

data abc1;
input A;
datalines;
20
;

%MACRO ABC(Data);
     proc fastclus data=&Data maxc=2 out=corrCluster noprint;
     run;
%MEND ABC;

proc iml;     
     use abc1;
     read all into X1;
			
     if(nrow(X1)>=2) then
     do;
   	%ABC(abc1);
     end;
quit;

Can you plz tell how to fix above...

Or is there another way to do this?

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Make a macro for it .


%MACRO ABC(Data);
     %let dsid=%sysfunc(open( &data ));
     %let nobs=%sysfunc(attrn(&dsid, nlobs ));
     %let dsid=%sysfunc(close(&dsid));

    %if &nobs > 2 %then %do;
     proc fastclus data=&Data maxc=2 out=corrCluster noprint;
     run;
    %end;
%MEND ABC;




   	%ABC(abc1)

View solution in original post

1 REPLY 1
Ksharp
Super User

Make a macro for it .


%MACRO ABC(Data);
     %let dsid=%sysfunc(open( &data ));
     %let nobs=%sysfunc(attrn(&dsid, nlobs ));
     %let dsid=%sysfunc(close(&dsid));

    %if &nobs > 2 %then %do;
     proc fastclus data=&Data maxc=2 out=corrCluster noprint;
     run;
    %end;
%MEND ABC;




   	%ABC(abc1)

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 879 views
  • 2 likes
  • 2 in conversation