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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.