- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi I have a value for example 0,80 on a date 27/01/2021
I want a plot showing only one bar with the date 27/01/2021 and with a percentage scale, so this bar will reach 80%. The bar should also contain a label "80 %" inside the bar
how can I do so?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
See if you can use this as a template.
data plot;
x = today();
y = .8;
run;
proc sgplot data = plot;
vbarparm category = x response = y / datalabel datalabelattrs = (size = 20);
yaxis min = 0 max = 1;
format x date9. y percent.;
xaxis display = (nolabel);
yaxis display = (nolabel);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sql;
select distinct wanted_sum into :nobs
from sumtable_0;
quit;
%put nobs=&nobs;
**second value;
proc sql;
select distinct wanted_sum into :kobs
from sumtable_1;
quit;
%put kobs=&kobs;
**calculation;
&kobs/&nobs
I made this macro where I get two different values everyday from my dataset fx in this case the wanted_sum from sumtable_0 is 4559099 and from sumtable_1 it is 3578989
everyday new numbers appears - these are from today.
then i divide them 3578989/4559099
the result of this should be the one bar plot in percentage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure I understand. You have a single value 0.8 that you want in a bar chart? That bar chart would have one bar only?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes only one bar.
date = today()
and y axis should be from 0 to 100%
Also a label in the bar with the number of percentages it is in this case 80%
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
See if you can use this as a template.
data plot;
x = today();
y = .8;
run;
proc sgplot data = plot;
vbarparm category = x response = y / datalabel datalabelattrs = (size = 20);
yaxis min = 0 max = 1;
format x date9. y percent.;
xaxis display = (nolabel);
yaxis display = (nolabel);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much!
I got one bar - the bare is very big - is it possible to adjust the size of a bar in the width?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sure. Use the Barwidth Option on the VBARPARM Statement.
data plot;
x = today();
y = .8;
run;
proc sgplot data = plot;
vbarparm category = x response = y / datalabel datalabelattrs = (size = 20) barwidth=.2;
yaxis min = 0 max = 1;
format x date9. y percent.;
xaxis display = (nolabel);
yaxis display = (nolabel);
run;
Result:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can i make the y-axis go up to 100%
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Of course. Here is the documentation for the SGPLOT procedure.
You can control the axes by using the XAXIS (horizontal axis) and YAXIS statements (vertical). Look at the MIN= and MAX= options on the YAXIS statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sgplot data = plot;
vbarparm category = x response = y / datalabel datalabelattrs = (size = 10)barwidth=.2;
yaxis min = 0 max = 1;
format x date9. y percent.;
xaxis display = (nolabel);
yaxis display = (nolabel);
Title1 font = 'Calibri' height=16pt "Ande";
run;
it does not work - can you help
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sgplot data = plot;
vbarparm category = x response = y / datalabel datalabelattrs = (size = 10)barwidth=.2;
format x date9. y percent.;
xaxis display = (nolabel);
yaxis display = (nolabel) MAX=1;
Title1 font = 'Calibri' height=16pt "Ande";
run;