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
Super User

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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