I am using this code to get percent of bars within group (data_column_C), but what I am getting is percent within data_column_A category.
Basically I want the percents to sum up to 100% for data_column_C and have individual bar by data_column_A.
proc sgplot data=data_table pctlevel=group; vline data_column_A /response=data_column_B stat=mean limitstat=clm markers group=data_column_C lineattrs=(thickness=2); vbar data_column_A / response=data_column_B y2axis transparency=0.75 group=data_column_C groupdisplay=cluster stat=percent; run;
The way you can do this is to transpose the data such that the values in DATA_COLUMN_B are put into DATA_COLUMN_B1 and DATA_COLUMN_B2, depending on the value in DATA_COLUMN_C. Then, your plot becomes 2 vbar sttements with stat=mean and 2 vline statements with stat=percent. The PCTLEVEL option will not be required.
Hope this helps!
i think this is a much needed function in sgplot.
my work-around is to use proc freq to export the percentages and then use sgplot. like
proc freq data=xxx noprint;table a*b/out=XXXX outpct;run;
proc sgplot data=XXXX;vbar b /response=pct_row group=a groupdisplay=cluster;run;
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.
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.