Hi,
I am trying to plot a bar graph using SAS, and so far I have the following code:
DATA auto ;
INPUT resource $ percent ;
CARDS;
Google 73.6
Library 13.6
Wikipedia 9.4
Other 3.4
;
TITLE 'Simple Vertical Bar Chart ';
PROC SGPLOT DATA=auto;
vbar resource;
run;
quit;
I am using the student version of SAS provided free through my university hence the usage of SGPLOT. When I run the code, however, instead of showing the percentages of each resource, it plots the frequencies so all the bars show as 1 unit length. I am trying to plot resources, the independent variable, vs the percentage, the dependent variable. I tried using vbar resource/ DISCRETE, but received an error message stating that I can only use DISCRETE to offset the bins. I would appreciate any tips and additional resources to consult as I am new to SAS. Thank you!
DATA auto ;
INPUT resource $ percent ;
CARDS;
Google 73.6
Library 13.6
Wikipedia 9.4
Other 3.4
;
TITLE 'Simple Vertical Bar Chart ';
PROC SGPLOT DATA=auto;
vbar resource/respose=percent datalabel nostatlabel;
run;
quit;
DATA auto ;
INPUT resource $ percent ;
CARDS;
Google 73.6
Library 13.6
Wikipedia 9.4
Other 3.4
;
TITLE 'Simple Vertical Bar Chart ';
PROC SGPLOT DATA=auto;
vbar resource/respose=percent datalabel nostatlabel;
run;
quit;
Thank you for your response!
Welcome to the SAS communities 🙂
Please see se blog post Getting started with SGPLOT for an introduction to the VBAR Statement in PROC SGPLOT.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.