Data visualization with SAS programming

Need help in creating a graph in SAS EG

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Need help in creating a graph in SAS EG

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


Accepted Solutions
Solution
‎09-01-2017 10:14 AM
SAS Super FREQ
Posts: 925

Re: Need help in creating a graph in SAS EG

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;

View solution in original post


All Replies
Solution
‎09-01-2017 10:14 AM
SAS Super FREQ
Posts: 925

Re: Need help in creating a graph in SAS EG

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;
Occasional Contributor
Posts: 15

Re: Need help in creating a graph in SAS EG

[ Edited ]

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

SAS Super FREQ
Posts: 925

Re: Need help in creating a graph in SAS EG

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;
Occasional Contributor
Posts: 15

Re: Need help in creating a graph in SAS EG

Thank you very much Dan for your help. This is what I have been trying for. Can you suggest me any book or material where I can learn more about charts and plots in EG?

Thanks,
Jay
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 194 views
  • 0 likes
  • 2 in conversation