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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.