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

hi,

this is the graph I need to build:

IditMaor_0-1655623064032.jpeg

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

 

 

1 ACCEPTED SOLUTION

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

Ksharp_0-1655633062179.png

 

View solution in original post

5 REPLIES 5
Ksharp
Super User
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;

Ksharp_0-1655633062179.png

 

IditMaor
Calcite | Level 5

thank you very much.

I have another question.

this id the second graph I need to do:

IditMaor_0-1655635603123.png

now, how do I add several lines on the bar?

Idit Maor

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

Ksharp_0-1655725792142.png

 

IditMaor
Calcite | Level 5

thank you very much.

this is what I need

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

Ksharp_0-1655633417081.png

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 5 replies
  • 887 views
  • 2 likes
  • 2 in conversation