Sankey Bar Charts - SAS More Options

More Options

Following are examples using additional optional parameters of the %SankeyBarChart macro (downloadable on the Macro page).

We begin by regenerating the Getting Started example.


*------------------------------------------------------------;
*---------- dummy data generation ----------;
*------------------------------------------------------------;

data dummy;
   do subject = 1 to 100;
      do visit = -1, 12, 30, 60;
         random = rannor(1) + 0.5 + (visit+1)/30;
         riskfactors = min(3,floor(abs(random)));
         output;
      end;
   end;
run;


*------------------------------------------------------------;
*---------- original ----------;
*------------------------------------------------------------;

proc format;
   value xfmt
   1 = 'Baseline'
   2 = 'Month 12'
   3 = 'Month 30'
   4 = 'Month 60'
   ;
run;

%sankeybarchart
   (data=dummy
   ,subject=subject
   ,yvar=riskfactors
   ,xvar=visit
   ,yvarord=%quote(0, 1, 2, 3)
   ,barwidth=0.45
   ,xfmt=xfmt.
   ,legendtitle=%quote(# of Risk Factors)
   );

There is an option (PERCENTS=) to turn off the annotations of the percent values in each bar segment.


*------------------------------------------------------------;
*---------- remove the percents ----------;
*------------------------------------------------------------;

%sankeybarchart
   (data=dummy
   ,subject=subject
   ,yvar=riskfactors
   ,xvar=visit
   ,yvarord=%quote(0, 1, 2, 3)
   ,barwidth=0.45
   ,xfmt=xfmt.
   ,legendtitle=%quote(# of Risk Factors)
   ,percents=no
   );

There is an option (INTERPOL=) to straighten the links connecting the bar segments.


*------------------------------------------------------------;
*---------- straight links ----------;
*------------------------------------------------------------;

%sankeybarchart
   (data=dummy
   ,subject=subject
   ,yvar=riskfactors
   ,xvar=visit
   ,yvarord=%quote(0, 1, 2, 3)
   ,barwidth=0.45
   ,xfmt=xfmt.
   ,legendtitle=%quote(# of Risk Factors)
   ,interpol=linear
   ,percents=no
   );

Lastly, there is an option (COLORLIST=) to change the default colors.


*------------------------------------------------------------;
*---------- new colors ----------;
*------------------------------------------------------------;

%sankeybarchart
   (data=dummy
   ,subject=subject
   ,yvar=riskfactors
   ,xvar=visit
   ,yvarord=%quote(0, 1, 2, 3)
   ,colorlist=cxfdcc8a cxfc8d59 cxe34a33 cxb30000
   ,barwidth=0.45
   ,xfmt=xfmt.
   ,legendtitle=%quote(# of Risk Factors)
   ,interpol=linear
   ,percents=no
   );

Data

The above code generates raw data with random number functions. No data download is necessary.

top