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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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