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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

View solution in original post

3 REPLIES 3
Ksharp
Super User

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;
Fara_I
Fluorite | Level 6

Thank you for your response!

PeterClemmensen
Tourmaline | Level 20

Welcome to the SAS communities 🙂

 

Please see se blog post Getting started with SGPLOT for an introduction to the VBAR Statement in PROC SGPLOT. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3 replies
  • 1842 views
  • 0 likes
  • 3 in conversation