BookmarkSubscribeRSS Feed
gzr2mz39
Quartz | Level 8
I have data that looks like this:
month count
1 10
2 20
4 19
5 5

How do I plot month=3 as count=0?

Thank you.
6 REPLIES 6
Bill
Quartz | Level 8
data test;
input month count ;
cards;
1 10
2 20
3 0
4 19
5 5
;
goptions dev=win;
proc gchart;
vbar month/sumvar=count
discrete

;
run;
GraphGuy
Meteorite | Level 14
Or, without inserting data, you could use a gplot needle plot (which used a proportional axis, rather than only plotting bars for the points you have data at), such as ...

data test;
input month count ;
cards;
1 10
2 20
4 19
5 5
;

symbol1 value=none interpol=needle width=15;
axis1 order=(1 to 5 by 1) minor=none offset=(5,5);
axis2 order=(0 to 25 by 5) minor=none offset=(0,0);
proc gplot data=test;
plot count*month=1 / haxis=axis1 vaxis=axis2;
run;
gzr2mz39
Quartz | Level 8
This looks good.
Is it possible to use lines instead of bars?
Thank you.
GraphGuy
Meteorite | Level 14
Certainly! - That would be the very basic line plots - described in more detail in the doc - you've checked there first, right? 🙂


All you'd have to do is modify the symbol statement in the above example, as follows:

data test;
input month count ;
cards;
1 10
2 20
4 19
5 5
;

symbol1 value=dot height=2 interpol=join;
axis1 order=(1 to 5 by 1) minor=none offset=(5,5);
axis2 order=(0 to 25 by 5) minor=none offset=(0,0);
proc gplot data=test;
plot count*month=1 / haxis=axis1 vaxis=axis2;
run;


Or, if you want to have a "gap" in the line plot, where the value at 3 is missing, then insert a SAS "missing value" in the data, and use the 'skipmiss' gplot option...

data test;
input month count ;
cards;
1 10
2 20
3 .
4 19
5 5
;

symbol1 value=dot height=2 interpol=join;
axis1 order=(1 to 5 by 1) minor=none offset=(5,5);
axis2 order=(0 to 25 by 5) minor=none offset=(0,0);
proc gplot data=test;
plot count*month=1 / haxis=axis1 vaxis=axis2 skipmiss;
run;
proc print data=test; run;
gzr2mz39
Quartz | Level 8
I liked how the needle plot reflected count=0.
I was hoping there was a better way to reflect count=0 with the line plot (ie the line actually goes down to 0 instead of just not display a dot).
GraphGuy
Meteorite | Level 14
To do that, you'd have to insert a zero value into the data...

data test;
input month count ;
cards;
1 10
2 20
3 0
4 19
5 5
;

symbol1 value=dot height=2 interpol=join;
axis1 order=(1 to 5 by 1) minor=none offset=(5,5);
axis2 order=(0 to 25 by 5) minor=none offset=(0,0);
proc gplot data=test;
plot count*month=1 / haxis=axis1 vaxis=axis2;
run;

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1937 views
  • 0 likes
  • 3 in conversation