Hello All,
I have the following data
SUBCATEGORY Pieces defects Failure%
product 1 248 41 17
product 2 252 80 32
product 3 127 23 18
product 4 397 6 2
product 5 107 8 7
product 6 52 10 19
product 7 79 0 0
product 8 174 4 2
product 9 670 134 20
product 10 227 23 10
product 11 383 8 2
product 12 110 20 18
product 13 461 7 2
product 14 182 66 36
product 15 83 17 20
product 16 130 1 1
product 17 176 0 0
Can i create a graph that is attached in enterprise guide
Thanks,
jay
This code should do it for you:
data products;
label Failure="Failure%";
input SUBCATEGORY $ 1-10 Pieces defects Failure;
cards;
product 1 248 41 17
product 2 252 80 32
product 3 127 23 18
product 4 397 6 2
product 5 107 8 7
product 6 52 10 19
product 7 79 0 0
product 8 174 4 2
product 9 670 134 20
product 10 227 23 10
product 11 383 8 2
product 12 110 20 18
product 13 461 7 2
product 14 182 66 36
product 15 83 17 20
product 16 130 1 1
product 17 176 0 0
;
run;
proc sgplot data=products;
xaxis display=(nolabel);
yaxis display=(nolabel);
vbarparm category=subcategory response=pieces / datalabel discreteoffset=-0.3 barwidth=0.25;
vbarparm category=subcategory response=defects / datalabel barwidth=0.25;
vbarparm category=subcategory response=failure / datalabel discreteoffset=0.3 barwidth=0.25;
run;
This code should do it for you:
data products;
label Failure="Failure%";
input SUBCATEGORY $ 1-10 Pieces defects Failure;
cards;
product 1 248 41 17
product 2 252 80 32
product 3 127 23 18
product 4 397 6 2
product 5 107 8 7
product 6 52 10 19
product 7 79 0 0
product 8 174 4 2
product 9 670 134 20
product 10 227 23 10
product 11 383 8 2
product 12 110 20 18
product 13 461 7 2
product 14 182 66 36
product 15 83 17 20
product 16 130 1 1
product 17 176 0 0
;
run;
proc sgplot data=products;
xaxis display=(nolabel);
yaxis display=(nolabel);
vbarparm category=subcategory response=pieces / datalabel discreteoffset=-0.3 barwidth=0.25;
vbarparm category=subcategory response=defects / datalabel barwidth=0.25;
vbarparm category=subcategory response=failure / datalabel discreteoffset=0.3 barwidth=0.25;
run;
Hi Dan,
Thanks for the quick reply. One question how can I change the failure% in the above data to a line in the same chart. To make it a Dual axis bar line chart.
Thanks,
Jay
See if this will get you what you want:
proc sgplot data=products cycleattrs;
xaxis display=(nolabel);
yaxis display=(nolabel);
vbarparm category=subcategory response=pieces / datalabel discreteoffset=-0.2 barwidth=0.4;
vbarparm category=subcategory response=defects / datalabel discreteoffset=0.2 barwidth=0.4;
series x=subcategory y=failure / datalabel y2axis lineattrs=(thickness=2);
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.