BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a list of ages and blood pressures for 10000 people. How do I create a gchart bar chart to show average blood pressure for people in their 20s, 30s, 40s, 50, 60s, 70s 80s? I've gotten to:

proc gchart data= survey;
vbar age / midpoints = 20 to 80 by 10;
run;

which isn't all that close. I can't figure out how to include the average blood pressure (variable: sys) as well. Thanks in advance. Message was edited by: YaoPau
3 REPLIES 3
Ksharp
Super User
Hi.
Your vbar variable is numeric , so SAS will automatically compute midpoint of horizontal axis.
You need option ' discrete ' to fit the axis or change 'age' into character type.

[pre]
proc gchart data= sashelp.class;
vbar age / midpoints = 11 to 15 sumvar=height type=mean discrete;
run;
[/pre]


P.S. Actually If you post your question to the 'SAS graphic',There is a sas-man named Robort would solve it.


Ksharp

Message was edited by: Ksharp
ArtC
Rhodochrosite | Level 12
You are actually quite close, to incorporate KSharps answer (untested):
[pre]proc gchart data= survey;
vbar age / midpoints = 20 to 80 by 10
sumvar=pressure type=mean;
run;
[/pre]

Groups for your numeric variable can also be formed using a format. Using the DISCRETE option will give you one level per value for age.
data_null__
Jade | Level 19
This program indicates that the ages are rounded to the midpoint values, as the first two bar charts appear to be the same. I you want age ranges 20-29, 30-39 etc. you will need to create a format or a new variable as in AGEG2.



[pre]
proc plan seed=1245760598;
factors subj=10000 ordered age=1 of 65 sys=1 of 91;
output out=survey age nvals=(20 to 84) sys nvals=(50 to 140);
run;
quit;
data survey;
set survey;
ageg = round(age,10);
ageg2 = floor(age/10)*10;
run;
proc print data=_last_(obs=100);
run;

proc gchart data= survey;
Hbar age / midpoints = 20 to 80 by 10 sumvar=sys type=mean;
Hbar ageg / discrete sumvar=sys type=mean;
Hbar ageg2 / discrete sumvar=sys type=mean;
run;
quit;
[/pre]

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 721 views
  • 0 likes
  • 4 in conversation