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?
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;
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.
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?
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%
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;
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?
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:
Can i make the y-axis go up to 100%
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.
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
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;
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.