Data visualization with SAS programming

Proc GCHART Date X axis

Reply
Occasional Contributor
Posts: 5

Proc GCHART Date X axis

Hi,

I am trying to plot a simple bar chart in SAS 9.3. My data looks like this:

Date              Plot

07jan2010      10

12jan2010      4

22feb2010      1

etc.

Using the following code:

proc gchart data=dataset;

     vbar plot / discrete sumvar = plot

     type=sum;

run;

quit;

The axis that shows is a text axis -- the dates for which no observations exist in the dataset (ex.: Jan 8 2010) do not show up on the x axis.  Does anyone have corrections to my codes?

Thanks,

Matt

Contributor n6
Contributor
Posts: 55

Re: Proc GCHART Date X axis

Is the date variable stored as a date or as text?  If it's text then 25Jan2010, for instance, would show up after 22Feb2010 even though you woudn't want it to.

Also, you say that the dates for which there are no observations in the dataset don't show up on the x-axis.  Isn't that a good thin?  I mean, if there are 0 observations for Feb 1, 2010, wouldn't you want it to just not show up on the x-axis instead of having it say Feb 1, 2010 on the x-axis and then have a blank space above it where there is no bar because it Feb 1, 2010 wasn't in the dataset?

Occasional Contributor
Posts: 5

Re: Proc GCHART Date X axis

The date variable is stored as date..

I'd prefer to have missing bars for Feb 1, 2010 so that the x-axis has a common interval.

SAS Super FREQ
Posts: 864

Re: Proc GCHART Date X axis

This should work for you:

data dataset;

informat date date9.;

format date date9.;

input date $ plot;

cards;

07jan2010      10

12jan2010      4

22feb2010      1

;

run;


proc gchart data=dataset;

     vbar date / discrete sumvar = plot

                 type=sum midpoints=('07jan2010'd to '22feb2010'd);

run;

quit;

Post a Question
Discussion Stats
  • 3 replies
  • 420 views
  • 0 likes
  • 3 in conversation