🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 11-12-2015 04:44 PM
(2259 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use response instead of weight.
proc sgplot data=class;
vbar age / response=count;
run;
proc sgplot data=class;
vbar age / response=count;
run;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use response instead of weight.
proc sgplot data=class;
vbar age / response=count;
run;
proc sgplot data=class;
vbar age / response=count;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thanks for this!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
"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;