BookmarkSubscribeRSS Feed
minfante
Calcite | Level 5

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

3 REPLIES 3
n6
Quartz | Level 8 n6
Quartz | Level 8

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?

minfante
Calcite | Level 5

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.

DanH_sas
SAS Super FREQ

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1926 views
  • 0 likes
  • 3 in conversation