In SAS 9.3, you will easily be able to associate visual attributes with data values in what's called an "attribute map". In the meantime, you can use an INDEX in GTL to create the linkage. The following program should get you what you want. Let me know if you have any questions.
Thanks!
Dan
proc template;
Define style styles.mystyle;
Parent=styles.listing;
Style graphdata1 from graphdata1 / contrastcolor=grey color=CX84AF5B; /* green */
Style graphdata2 from graphdata2 / contrastcolor=grey color=CXF1DC63; /* yellow */
Style graphdata3 from graphdata3 / contrastcolor=grey color=CXC95A49; /* red */
end;
run;
data sentiment;
input category $ sentiment_category $ COUNT percent graph_order;
cards;
Car Positive 3 10 1
Car Neutral 1 3 2
Car Negative 26 87 3
General Positive 12 60 1
General Neutral 0 0 2
General Negative 8 40 3
Price Positive 1 33 1
Price Neutral 0 0 2
Price Negative 2 67 3
Service Positive 24 67 1
Service Neutral 0 0 2
Service Negative 12 33 3
;
run;
data indexed;
set sentiment;
if (sentiment_category eq "Positive") then index=1;
if (sentiment_category eq "Neutral") then index=2;
if (sentiment_category eq "Negative") then index=3;
run;
proc template;
define statgraph barchart;
begingraph;
layout overlay / xaxisopts=( Label=" " ) yaxisopts=( griddisplay=on Label=" " linearopts=(Integer=true));
BarChart X=category Y=Count / Group=sentiment_category index=index NAME="VBAR";
DiscreteLegend "VBAR"/ title="sentiment_category";
endlayout;
endgraph;
end;
run;
ods listing style=mystyle;
proc sgrender data=indexed template=barchart; run;
Works great! Thanks a lot Dan
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.