I have a table 'have' with the following columns.
ID
AgeGroup: 18-24, 25-29, 30-34, 35-39, 40-44, 45-49, 50-59, 60+
Gender: F, M
Race: Black, White, Hispanic, Asian, Hawiian/AmIndian, Other
Vaccination Status: Full, Partial, None
Sample table
data have;
input ID AgeGroup $ Gender $ Race $ VaccinStatus $;
datalines;
100 18-24 F Asian Full
101 25-29 M Hispanic Full
102 18-24 F White None
103 55+ M White Full
104 40-44 F Hispanic None
105 18-24 M Asian Full
106 50-54 M White Full
107 30-34 M Asian None
108 18-24 M Hispanic Full
109 40-44 M White Partial
110 45-49 M Other Full
111 55+ F Asian Full
112 40-44 M Other Partial
113 35-39 F Hawaiian Partial
114 25-29 M Asian Full
115 40-44 M Hawaiian Full
116 30-34 F White Partial
117 40-44 F White Full
118 45-49 F Asian Full
119 18-24 M Hispanic Full
120 25-29 F White None
121 55+ M White Full
122 45-49 F Hispanic None
123 50-54 M Asian Full
124 30-34 M White Full
125 40-44 M Asian None
126 18-24 M Hispanic Full
127 55+ M White Partial
128 35-39 M Other Full
129 50-54 F Asian Full
130 18-24 M Other Partial
131 35-39 F Hawaiian Partial
132 45-49 M Asian Full
133 40-44 M Hawaiian Full
134 30-34 F White Partial
135 18-24 F White Full
run;
I would like to create a 100% stacked bar chart where AgeGroup with categories, Gender with categories, Race with categories will be on the X-axis and Vaccination Status will be on the Y-axis.
I tried the following code but failed.
Proc SGPLOT data=Have pctlevel=group; Vbar AgeGroup, Gender, Race / group = VaccinStatus Stat=percent; Title 'Vaccination Status by Age, gender and race'; Xaxis discreteorder=data; YAXIS grid values=(0 to 100 by 10); run; quit;
Error Log:
NOTE: Writing HTML5(EGHTML) Body file: EGHTML 27 28 Proc SGPLOT data=Have pctlevel=group; 29 Vbar AgeGroup, Gender, Race / group = VaccinStatus Stat=percent; _ 22 200 ERROR 22-322: Syntax error, expecting one of the following: ;, /. ERROR 200-322: The symbol is not recognized and will be ignored. 30 Title 'Vaccination Status by Age, gender and race'; 31 Xaxis discreteorder=data; 32 YAXIS grid values=(0 to 100 by 10); 33 run;
... View more