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. 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1245 views
  • 0 likes
  • 3 in conversation