BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mmea
Quartz | Level 8

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?

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

11 REPLIES 11
PeterClemmensen
Tourmaline | Level 20

Try the VBARPARM Statement 🙂

 

Provide sample data if you want a full code answer.

mmea
Quartz | Level 8
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.

PeterClemmensen
Tourmaline | Level 20

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?

mmea
Quartz | Level 8

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%

 

PeterClemmensen
Tourmaline | Level 20

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;
mmea
Quartz | Level 8

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?

 

 

PeterClemmensen
Tourmaline | Level 20

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:

 

sgplot.PNG

 

mmea
Quartz | Level 8

Can i make the y-axis go up to 100%

Rick_SAS
SAS Super FREQ

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.

mmea
Quartz | Level 8
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

Rick_SAS
SAS Super FREQ
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;

SAS Innovate 2025: Register Now

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!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 11 replies
  • 1477 views
  • 4 likes
  • 3 in conversation