BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
morglum
Quartz | Level 8

I have a dataset with aggregated date and I would like to create a VBAR to show the distribution of the variables.  I thought using the weight option would work, but it doesnt.  For example, in the example below all the frequencies stand at "1", instead of using the count variable which should be somewhere between 1 and 5.

 

What is going on?  I'm using SAS 9.3 on a windows machine.

Cheers!

 

 

proc sql;
create table class as
select distinct age, count(*) as count
from sashelp.class
group by age;
quit;

proc sgplot data=class;
vbar age / weight=count;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Use response instead of weight.

proc sgplot data=class;
vbar age / response=count;
run;

View solution in original post

4 REPLIES 4
Reeza
Super User
Use response instead of weight.

proc sgplot data=class;
vbar age / response=count;
run;
morglum
Quartz | Level 8
thanks for this!
FreelanceReinh
Jade | Level 19

You can also use FREQ= instead of WEIGHT= if you prefer "Frequency" over "count (Sum)" as the label of the y-axis.

proc sgplot data=class;
vbar age / freq=count;
run;
morglum
Quartz | Level 8
Thanks for the reply!

"Frequency" does look better, but it wont graph non-integer numbers properly (such as count minus 0.5), which happens with surveys with probabilistic weights.

Cheers!

proc sql;
create table class as
select distinct age, count(*)-0.5 as count
from sashelp.class
group by age;
quit;

proc sgplot data=class;
vbar age / response=count;
yaxis label="frequency";
run;

proc sgplot data=class;
vbar age / freq=count ;
yaxis label="frequency";
run;

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!

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.

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