I want to replicate this excel graph in SAS to reuse in macro. I want to use both rrc and frc as responses to the stack
proc sgplot data=main_subset;
vbar sam / response = rrc group=rep groupdisplay = cluster seglabel datalabel
stat=mean dataskin=gloss;
xaxis display=(nolabel noticks) discreteorder=data FITPOLICY=STAGGERROTATE;
yaxis label="reads";*grid;
run;
sam | rrc | frc | rep |
MES_TreatA | 229 | 1641852 | R1 |
MES_TreatA | 258 | 1152647 | R2 |
MES_TreatB | 187 | 929301 | R1 |
MES_TreatB | 530 | 2556723 | R2 |
MES_TreatC | 482255 | 574857 | R1 |
MES_TreatC | 534623 | 728475 | R2 |
MES_TreatD | 1015145 | 599958 | R1 |
MES_TreatD | 1987144 | 244161 | R2 |
MES_TreatE | 564 | 1838329 | R1 |
MES_TreatE | 209 | 2189893 | R2 |
Thank you
data main_subset;
infile cards expandtabs truncover;
input sam : $20. rrc frc rep $;
cards;
MES_TreatA 229 1641852 R1
MES_TreatA 258 1152647 R2
MES_TreatB 187 929301 R1
MES_TreatB 530 2556723 R2
MES_TreatC 482255 574857 R1
MES_TreatC 534623 728475 R2
MES_TreatD 1015145 599958 R1
MES_TreatD 1987144 244161 R2
MES_TreatE 564 1838329 R1
MES_TreatE 209 2189893 R2
;
data main_subset2;
set main_subset;
sam=catx('_',sam,rep);
id='rrc';value=rrc;output;
id='frc';value=frc;output;
keep sam id value;
run;
proc sgplot data=main_subset2;
vbar sam / response = value group=id grouporder=descending nooutline;
xaxis display=(nolabel noticks) discreteorder=data VALUESROTATE=DIAGONAL2
FITPOLICY=ROTATE valuesformat=$10.;
yaxis label="reads" grid ;
keylegend /title='' noborder autooutline;
run;
data main_subset;
infile cards expandtabs truncover;
input sam : $20. rrc frc rep $;
cards;
MES_TreatA 229 1641852 R1
MES_TreatA 258 1152647 R2
MES_TreatB 187 929301 R1
MES_TreatB 530 2556723 R2
MES_TreatC 482255 574857 R1
MES_TreatC 534623 728475 R2
MES_TreatD 1015145 599958 R1
MES_TreatD 1987144 244161 R2
MES_TreatE 564 1838329 R1
MES_TreatE 209 2189893 R2
;
data main_subset2;
set main_subset;
sam=catx('_',sam,rep);
id='rrc';value=rrc;output;
id='frc';value=frc;output;
keep sam id value;
run;
proc sgplot data=main_subset2;
vbar sam / response = value group=id grouporder=descending nooutline;
xaxis display=(nolabel noticks) discreteorder=data VALUESROTATE=DIAGONAL2
FITPOLICY=ROTATE valuesformat=$10.;
yaxis label="reads" grid ;
keylegend /title='' noborder autooutline;
run;
Thank you so much. It worked very well.
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.