Programming the statistical procedures from SAS

Nearest neighbor with Proc Modeclus

Reply
New Contributor
Posts: 3

Nearest neighbor with Proc Modeclus

I am trying to get a list of nearest neighbors for a dataset using Proc Modeclus.  It appears to be working well, except there is a limit to the ID and neighbor value that I need to change.  It appears to be limited to 5 characters, and I need more than that.  Does anyone know a way to change this?

ods _all_ close;

proc modelus data=in1 dk=11 neighbor;

     var xpos ypos;

ods output test1;

run;

in1 has 861,075 observations, and the listing I get gives the nearest neighbor if the observation values are less than or equal to 99,999, but uses ***** for values larger than that. 

Thank you for your help.

PROC Star
Posts: 7,416

Nearest neighbor with Proc Modeclus

Which output table is truncating the results?  It may be a column that simply needs to be assigned a wider format via proc template.

New Contributor
Posts: 3

Nearest neighbor with Proc Modeclus

That is a great idea, but I don't know where the 5 character limit is being defined.  I changed the template for Neighbor, and formatted the values to be 8 characters long, and so the format changed, but the length did not. 

PROC Star
Posts: 7,416

Nearest neighbor with Proc Modeclus

I would have thought the default of 8 characters would have been applied::

OUTLENGTH=n
OUTL=n

specifies the length of those output variables that are not copied from the input data set but are created by PROC MODECLUS.

The OUTLENGTH= option applies only to the following variables that appear in all of the output data sets: _K_, _DK_, _CK_, _R_, _DR_, _CR_, _CASCAD_, _METHOD_, _NJOIN_, and _LOCAL_.

The minimum value is 2 or 3, depending on the operating system. The maximum value is 8. The default value is 8.

New Contributor
Posts: 3

Nearest neighbor with Proc Modeclus

Ok, I think I found the problem.  To define a length for the output, you have to define an ID variable.  I defined the length of the ID variable in the data step just to make sure.

data in1;

set in1;

idv=_n_;

ods _all_ close;

proc modelus data=in1 dk=11 neighbor;    

var xpos ypos;

id idv;

ods output test1;

run;

Thank you for your help Art.

Ask a Question
Discussion stats
  • 4 replies
  • 232 views
  • 3 likes
  • 2 in conversation