The Density statement does not support GROUP role. In cases where you have a known number of group values, you could transpose your data into multiple columns and overlay the needed plots as shown below. You don't need the BY statement.
do i=1 to 100;
A = 20+20*ranuni(2);
B = 20+30*ranuni(3);
proc sgplot data=density;
density a / legendlabel='A';
density b / legendlabel='B';
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.