Creating Three-Dimensional Block Charts - SAS Programming

We could not leave this chapter without showing you a block chart or two. When one of the authors (RP) was designing "PROC NYASUG;", the newsletter of the New York Area SAS Users Group, he relied on the talents of another founding member, Akos Felsovalyi,to create the group logo as a PROC CHART block chart constructed to be reminiscent of a three dimensional New York City skyline.For the current example you use the CLINICAL database. Suppose you want to see the relationship between the type of visit (ROUTINE = Y or N) and the year in which the data were collected. You could always use PROC FREQ to generate a two-way table, but we all know how many PROC FREQs a picture is worth. And while you're at it, why not also create a block chart showing the mean SBP for each YEAR and value of ROUTINE. Before you create the block chart, you need to create the YEAR variable.This code, along with the PROC CHART statements, is shown next:

Example

DATA BLOCKEG;
SET CLINICAL (KEEP=DATE ROUTINE SBP);
YEAR=YEAR(DATE);
RON;
PROC CHART DATA=BLOCKEG;
TITLE 'Example Of a BLOCK CHART';
BLOCK YEAR / GROUP=ROUTINE DISCRETE; 0
BLOCK YEAR / GROUP*ROUTINE SUMVAR=SBP TYPE=MEAN DISCRETE; 2
FORMAT SBP 5.;
RON;

The first BLOCK statement 0 places YEAR on the horizontal axis, ROUTINE on the depth axis (into the page),and the number of visits for the given year and value of ROUTINE on the vertical axis.The DISCRETE option is necessary here since you want the actual YEAR values on the horizontal axis.The block chart produced by the first BLOCK statement is shown next:

Output from Example - Creating Three-Dimensional Block Charts - First BLOCK Statement

Output from Example - Creating Three-Dimensional Block Charts - First BLOCK Statement

The second BLOCK statement 2 uses the SUMVAR= and TYPE=MEAN options to give the mean SBP for each combination of YEAR and ROUTINE.You also provide a zero-decimal format for SBP so that you don't have long decimal values in the boxes.This chart is shown next:

Output from Example - Creating Three-Dimensional Block Charts - Second BLOCK Statement

Output from Example - Creating Three-Dimensional Block Charts - Second BLOCK Statement

To be honest, we should point out that there are many cases where block charts just don't work. If there are too many levels of the variables on the horizontal or vertical axis, the procedure will not be able to fit the block chart on the page (even with large LINESIZE= and PAGESIZE= options),and you will get an HBAR chart instead.As a matter of fact, we had to try several variables and data sets to find a block chart that we could use here as a demonstration.

PROC CHART can also produce pie and star charts, but we chose not to show examples of them here. For these types of charts, as well as for more refined looking charts of all kinds, we recommend the GCHART procedure which is part of SAS/GRAPH. PROC GCHART can output to true graphics devices unlike PROC CHART, which is designed to produce line-printer style charts.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SAS Programming Topics