BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Stalk
Pyrite | Level 9

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

Stalk_0-1675558780354.png

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
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;

Ksharp_0-1675592031423.png

 

View solution in original post

3 REPLIES 3
Ksharp
Super User
Why you have two the same "MES_TreatA" in the picture ?
Ksharp
Super User
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;

Ksharp_0-1675592031423.png

 

Stalk
Pyrite | Level 9

Thank you so much. It worked very well.

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1540 views
  • 1 like
  • 2 in conversation