- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone!
I'm having a dataset in SAS which looks similar to the below picture one and I am trying to create the same graph in SAS with proc sgplot and vbar, however, I struggle to be able to choose the two columns for the bars. With the response and group command I can only choose one of each...
I also tried it with two vbars in one proc sgplot and the response being for one active cases and for the other passive cases, however, that did not work properly.
Is there any way how I can achieve creating the below graph? Or do I have to change my dataset first, if yes, how? I'd prefer to stay with proc sgplot, if possible. Any help is greatly appreciated 🙂
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
VBAR wants the data structured differently. The stack value needs to be a variable. Something like this.
data have;
infile cards dsd;
input weekday $ var1 var2;
format datetime1 datetime2 datetime20.;
cards;
Monday,23,12
Tuesday,21,4
Wednesday,4,5
Thursday,5,29
Friday,8,9
;
run;
data want;
set have;
actual = var1; cat="cat1"; output;
actual = var2; cat="cat2"; output;
run;
proc sgplot data=want;
title 'Actual Sales by Day';
vbar weekday / response=actual group=cat stat=sum;
xaxis display=(nolabel);
yaxis grid label='Sales';
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
VBAR wants the data structured differently. The stack value needs to be a variable. Something like this.
data have;
infile cards dsd;
input weekday $ var1 var2;
format datetime1 datetime2 datetime20.;
cards;
Monday,23,12
Tuesday,21,4
Wednesday,4,5
Thursday,5,29
Friday,8,9
;
run;
data want;
set have;
actual = var1; cat="cat1"; output;
actual = var2; cat="cat2"; output;
run;
proc sgplot data=want;
title 'Actual Sales by Day';
vbar weekday / response=actual group=cat stat=sum;
xaxis display=(nolabel);
yaxis grid label='Sales';
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content