hi,
this is the graph I need to build:
1. how do I add the data in percent mark in yellow at the bottom?
2. how do I add the data above the bar (mark in yellow )?
regards,
Idit Maor
data path_resistance;
infile datalines delimiter = ',';
input pathGroup :$40. pathResistant $ resCount resPct total sub_total char : $80.;
format resPct percent8.0;
datalines;
Pathogen A,No,170,. ,. ,.,.
Pathogen A,Yes,33,.2 ,33,20,———
Pathogen B,No,100,. ,. ,.,.
Pathogen B,Yes,66,.14 ,66 ,50,———
Pathogen C,No,144,. ,. ,.,.
Pathogen C,Yes,44,.40 ,44 ,30,———
;
run;
proc sgplot data = path_resistance noautolegend noborder;
yaxis display = (nolabel) valueattrs = (color=black size=12pt);
xaxis grid min=0 label="Number of infections" ;
vbarparm category = pathGroup response = resCount /group = pathResistant
groupdisplay=cluster datalabel=total;
text x=pathGroup y=sub_total text=char/strip CONTRIBUTEOFFSETS=none position=right textattrs=(color=yellow size=20);
xaxistable resPct/location=inside position=bottom nolabel ;
xaxis display=(noline noticks nolabel);
yaxis grid display=(noline noticks);
run;
data path_resistance;
infile datalines delimiter = ',';
input pathGroup :$40. pathResistant $ resCount resPct total sub_total char : $80.;
format resPct percent8.0;
datalines;
Pathogen A,No,170,. ,. ,.,.
Pathogen A,Yes,33,.2 ,33,20,———
Pathogen B,No,100,. ,. ,.,.
Pathogen B,Yes,66,.14 ,66 ,50,———
Pathogen C,No,144,. ,. ,.,.
Pathogen C,Yes,44,.40 ,44 ,30,———
;
run;
proc sgplot data = path_resistance noautolegend noborder;
yaxis display = (nolabel) valueattrs = (color=black size=12pt);
xaxis grid min=0 label="Number of infections" ;
vbarparm category = pathGroup response = resCount /group = pathResistant
groupdisplay=cluster datalabel=total;
text x=pathGroup y=sub_total text=char/strip CONTRIBUTEOFFSETS=none position=right textattrs=(color=yellow size=20);
xaxistable resPct/location=inside position=bottom nolabel ;
xaxis display=(noline noticks nolabel);
yaxis grid display=(noline noticks);
run;
thank you very much.
I have another question.
this id the second graph I need to do:
now, how do I add several lines on the bar?
Idit Maor
data have;
infile cards expandtabs;
input min max Origin $ Type $ low high;
cards;
17 220 Asia SUV 17 220
23 30 Asia Sedan . .
30 37 Asia Sports . .
37 52 Asia Wagon . .
50 190 Europe SUV 15 190
100 127 Europe Sedan . .
127 135 Europe Sports . .
135 137 Europe Wagon . .
100 200 USA SUV 16 200
121 129 USA Sedan . .
129 134 USA Sports . .
134 151 USA Wagon . .
;
ods graphics / reset=all;
title 'Highway Mileage by Origin and Type';
proc sgplot data=have;
highlow y=origin high=max low=min / group=type type=bar
lowlabel=low highlabel=high ;
xaxis display=(nolabel) offsetmax=0.1 offsetmin=0.1;
yaxis display=(nolabel noticks) ;
keylegend /location=inside position=ne across=1;
run;
thank you very much.
this is what I need
data path_resistance;
infile datalines delimiter = ',';
input pathGroup :$40. pathResistant $ resCount resPct total sub_total char : $80.;
format resPct percent8.0;
datalines;
Pathogen A,No,170,. ,. ,.,.
Pathogen A,Yes,33,.2 ,33,20,———
Pathogen B,No,100,. ,. ,.,.
Pathogen B,Yes,66,.14 ,66 ,50,———
Pathogen C,No,144,. ,. ,.,.
Pathogen C,Yes,44,.40 ,44 ,30,———
;
run;
proc sgplot data = path_resistance noautolegend noborder;
yaxis display = (nolabel) valueattrs = (color=black size=12pt);
xaxis grid min=0 label="Number of infections" ;
vbarparm category = pathGroup response = resCount /group = pathResistant dataskin=pressed
groupdisplay=cluster datalabel=total;
text x=pathGroup y=sub_total text=char/strip CONTRIBUTEOFFSETS=none position=right textattrs=(color=yellow size=20);
xaxistable resPct/location=inside position=bottom nolabel ;
xaxis display=(noline noticks nolabel);
yaxis grid display=(noline noticks);
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.