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)

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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