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
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?
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.
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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.