Plug4
Plug4

Reputation: 3938

SAS: Box-and-Whisker Plots using multiple datasets

My objective is to create a Box-and-Whisker plot using data from multiple datasets. Important: the size the dataset are not the same - I am not sure if this can be an issue. I'm trying the following code:

 %macro plot;
    %do i=1 %to 10;
    ods graphics on;
    title 'Box Plot for Durations';
    proc boxplot data=d&i; /*where d&i refers to my datasets*/
    plot durations / *HERE I am also having some difficulties because I have to refer to a y(durations)*x values. But I only have a y(durations) the one I want to boxplot - my x corresponds to the different datasets where I take the value. 
         boxstyle = schematic
         nohlabel;
      label durations = 'Durations';
   run;
    %end;
    %mend plot;
   %plot;

I want my x values to refer to each datasets where I take the duration values to boxplot. Each d1 d2 d3...d10 are ten different datasets corresponding to 10 different firms. Therefore, I wish to have 10 boxplot on in one graph...any insights?

Upvotes: 0

Views: 1314

Answers (1)

Plug4
Plug4

Reputation: 3938

I figured that the best was to simply take all the data that I wish to plot from my datasets and merge them in one file. I created a unique id associated with each datasets prior to merging the data. Then its easy to box plot the data by doing:

title 'Box Plot for Durations';
    proc boxplot data=ALL_DATA; 
    plot boxplotdata*id / 
         boxstyle = schematic
         nohlabel;
      label durations = 'Durations';
   run;

Upvotes: 1

Related Questions