BookmarkSubscribeRSS Feed
adhunamukherjee
Fluorite | Level 6

Hello SAS Communities, 

 

I have the following table:

StateCdHypRelDeathIndFrequencyColPercent
IowaYes31.53
MississippiYes62.90
UtahYes21.18

 

I want to create a vertical bar chart which displays the percentage of people who experienced a hypertension-related death for each of the 3 states.
 
The x axis should be Iowa, Mississippi and Utah. The bar chart for each x value should be the ColPercent value. It should look as follows:
Project 3 graph.png
I have only generated a bar chart which takes in a variable and plots the frequency of each value of the variable as the weight of the variable. 

I am not sure how to use another column as the weight of the bar chart. I need to implement the PROC SGPLOT which can achieve this.

Thank you,
Adhuna Mukhopadhyay
2 REPLIES 2
ghosh
Barite | Level 11

There is a Weight option you can specify after the slash, but from your description I think you want to specify the colpct as a response

proc sgplot data=mydata;
  vbar StateCd /
    response=ColPct;
run;
AnnaWoolery
Calcite | Level 5

Hi Adhuna - to build off of what ghosh responded, below is the code I would use to achieve this 🙂

 

VBAR StateCd / RESPONSE = ColPercent
FILLATTRS = (COLOR = LIGHTSALMON)
DATALABEL = COLPercent;
FORMAT COLPercent 6.4;

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