%CENTROID Macro Autocall Macro

Retrieves the centroid positions of map data set polygons.

Variables written out:X, Y, ID variables
Requirement:It is not necessary to run the %ANNOMAC macro before using the %CENTROID macro.
Note:The %CENTROID autocall macro is available with Base SAS. The macro is no longer part of SAS/GRAPH, nor is SAS/GRAPH required to be installed to use this macro.
Tip:Use this macro as an aid in adding labels to a map. It can also be used in conjunction with the Base SAS GEODIST function when computing distances. See the GEODIST Function in SAS Functions and CALL Routines: Reference for more information.

Table of Contents

Syntax

%CENTROID (input-data-set, output-data-set, list-of-id-variables <, SEGONLY=n>);

Parameters

input-data-set

specifies a map data set. The input map data set must be sorted by the ID variables.

output-data-set

contains the ID variables and the X and Y variables.

list-of-id-variables

specifies the variables, each of which is assigned the centroid coordinates of each observation in the input-data-set. There is one observation for each unique set of ID values. If you specify more than one ID variable, then separate each variable with a space.

SEGONLY=n

specifies that only the nth segment of each map area is used to calculate the centroid. For example, if you specify SEGONLY=1, then only the first segment of each area is used.

Note: Be sure to end the list of ID variables with a comma before specifying a SEGONLY= value.
Last updated: September 13, 2021