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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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