stars stars - Star plot of multivariate data stars

SAS Macro Programs: stars

$Version: 1.7 (21 Dec 2005)
Michael Friendly
York University



STARS macro ( [download] get stars.sas)

The STARS macro draws a star plot of the multivariate observations in a data set, as described in "Section 8.4". Each observation is depicted by a star-shaped figure with one ray for each variable, whose length is proportional to the size of that variable. Each variable is scaled from 0 to 1. The STD= option permits the variables to be standardized to a given mean and standard deviation before this scaling. The SORTBY= option allows the observations to be sorted by a variable or a statistic. The VORDER= option allows the order of variables around the star to be rearranged according to their values on a given principal component.

Missing data

Observations with missing values can be assigned a default ray length or deleted from the stars plot.

Parameters

DATA=_LAST_
Name of the data set to be displayed.
VAR=_NUMERIC_
List of variables, in the order to be placed around the star, starting from angle=0 (horizontal), and proceeding counterclockwise.
ID=
Character observation identifier variable (required).
STD=
Standardizes the variables first to given mean and (optionally) a given standard deviation. STD=0 standardizes to mean=0; STD=0 1 standardizes to mean=0, std=1.
SORTBY=
Sorts the observations by a variable in the data set, or a statistic calculated across all variables in the VAR= list. If the SORTBY= value end in a '.', it is assumed to be the name of a statistic. For example SORTBY=SUM. sorts by the total of scaled values for all variables.
VORDER=
If VORDER=PRINn, the order of the VAR= variables is rearranged according to the values of the n-th principal component. VORDER=PRIN1 is often a good choice.
MINRAY=.1
Minimum ray length, 0<=MINRAY<1.
ACROSS=5
Number of stars across a page.
DOWN=6
Number of stars down a page. If the product of ACROSS and DOWN is less than the number of observations, multiple graphs are produced.
COLOR='BLACK'
Specifies the color used to draw individual observations, either as a quoted string constant, or the name of a variable in the input data set (but don't use COLOR=COLOR !).
MISSING=0.5
Specifies the ray length to be used when an observation has a missing value. Specify MISSING = . (a period) to have observations with missing values deleted.

GOPTIONS

The font used for text labels is controled by the FTEXT= setting. The HSIZE= and VSIZE= options should be used to scale the graph so that the individual stars are approxmately the same height and width.

Example

%include data(auto);
%include macros(stars) ;
data auto;
   set auto;
   length clr $8;
   price = -price;                  /* change signs so that large  */
   turn  = -turn;                   /* values represent 'good' cars*/
   gratio= -gratio;
   select(origin);
        when ('A') clr='RED    ';
        when ('E') clr='BLUE   ';
        when ('J') clr='GREEN  ';
   end;
      
%stars(
   data=auto,
   var = gratio  turn  rep77  rep78  price    mpg
         hroom rseat  trunk weight length displa,
   id=model,
   across=6, down=6, color=clr
      );