Programming the statistical procedures from SAS

Using Formats Created with PROC FORMAT as a Grouping Variable in PROC BOXPLOT

Reply
Contributor
Posts: 59

Using Formats Created with PROC FORMAT as a Grouping Variable in PROC BOXPLOT

Can you use a format that was created with Proc Format in PROC BOXPLOT in oder to compare several groups associated with the format "bins" into which you have divided the grouping variable.

 

PROC FORMAT ;
VALUE LEVELS

0 <- 2 = 'A'
2 <- 6 = 'B'
6 <- 10 = 'C'
10 <- 12 = 'D'
12 <- 16 = 'E';
RUN;

PROC FREQ
DATA = QUIZDATA ;
TABLES NLEVELS / PLOTS = FREQPLOT ;
FORMAT NLEVELS LEVELS. ;
RUN;

 

The format works well with PROC FREQ.

 

How would you use it with PROC BOXPLOT as I just wish to compare the five groups A -E and not all the individual values.

 

If one actually creates a new variable by binning the variable NLEVELS using the same groups  as in PROC FORMAT

then you can use this new variable in PROC BOXPLOT for comparison.

SAS Super FREQ
Posts: 3,547

Re: Using Formats Created with PROC FORMAT as a Grouping Variable in PROC BOXPLOT

A box plot shows the distribution of a continuous variable. What is the continuous variable here?  I am assuming that you want to create five box plots, one each for A-E?

 

If there is a continuoius variable called Y, you can create five box plots like this

proc boxplot data=quizdata;

FORMAT NLEVELS LEVELS. ;

PLOT Y*NLEVELS;

run;

 

If you are trying to visualize the distribution within each group, then try this:

data A / view=A;

Grade = NLEVELS;  /* copy continuous variable */

run;

 

proc boxplot data=A;

FORMAT NLEVELS LEVELS. ;

PLOT Grade*NLEVELS;

run;

 

Ask a Question
Discussion stats
  • 1 reply
  • 171 views
  • 0 likes
  • 2 in conversation