BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
twildone
Pyrite | Level 9

Hi...I am trying to create graphs for each question and would like to have the count and percentages on each graph. The counts on each bar are correct but the percentages seem to be incorrect. Any suggestion on why the percentages might be incorrect. Thanks.

 

data Table12;
    length Response $ 7 Term $ 9 Question $ 105 ;
    format Response $char7. Term $char9. Question $char105.;
    informat Response $char7. Term $char9. Question$char105.;
    infile datalines4 dlm='7F'x missover dsd;
    input Response : $char7. Term : $char9. Question : $char105.;
datalines4;
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I feel better prepared for the workplace because of taking this program.
MissingJune 2019I feel better prepared for the workplace because of taking this program.
MissingJune 2019I feel better prepared for the workplace because of taking this program.
NeutralJune 2019I feel better prepared for the workplace because of taking this program.
NeutralJune 2019I feel better prepared for the workplace because of taking this program.
AgreeJune 2019I had a good understanding of what I would learn in this program.
AgreeJune 2019I had a good understanding of what I would learn in this program.
AgreeJune 2019I had a good understanding of what I would learn in this program.
AgreeJune 2019I had a good understanding of what I would learn in this program.
AgreeJune 2019I had a good understanding of what I would learn in this program.
AgreeJune 2019I had a good understanding of what I would learn in this program.
AgreeJune 2019I had a good understanding of what I would learn in this program.
DisagreeJune 2019I had a good understanding of what I would learn in this program.
DisagreeJune 2019I had a good understanding of what I would learn in this program.
MissingJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
NeutralJune 2019I had a good understanding of what I would learn in this program.
;;;;


Axis1 style=1 width=1 minor=none label=(height=9pt font="arial/bold" angle=90  "Percent") value=(height=9pt font="arial" "0%" "10%" "20%" "30%" "40%" "50%" "60%" "70%" "80%" "90%" "100%");
Axis2 style=1 width=2 label=(height=9pt font="arial/bold"   "Response") value=(height=9pt font="arial");
Axis3 label=(height=9pt font="arial/bold"   "Term") value=(height=9pt font="arial");

proc gchart data=Table12;
	vbar Response / discrete group=Term type=percent inside=percent outside=freq nolegend g100
		coutline=black raxis=axis1 maxis=axis2 gaxis=axis3 woutline=1 patternid=midpoint width=20;
	by Question ;
run; 
quit;
1 ACCEPTED SOLUTION

Accepted Solutions
RichardDeVen
Barite | Level 11

I do see the problem now, the ACTXIMG bars do not appear to be to scale.

The percentage values show in the hover text is correct though.

 

I think the problem is your expectation more so than the Proc.

 

The vertical axis statement VALUE= option controls the text labels on the major tick marks but DOES NOT DEFINE those tick values.  The tick values must by specified in the ORDER= option.  The ACTXIMG major ticks that you are experiencing are not 0 to 100, but you are labeling them so and therein lies the confusion.

 

Change the AXIS statement to 

 

Axis1 style=1 width=1 minor=none 
  label=(height=9pt font="arial/bold" angle=90  "Percent") 
  value=(height=9pt font="arial" "0%" "10%" "20%" "30%" "40%" "50%" "60%" "70%" "80%" "90%" "100%" )
order = 0 to 100 by 10 /* <---- need this */ ;

View solution in original post

4 REPLIES 4
RichardDeVen
Barite | Level 11

What percentages were you expecting to see ?

 

Is it possible GROUP=TERM G100 is computing percentages different than you expectation ?

 

The chart numbers do appear correct.  These are the numbers I see

Question 1
June 2019
Response N % (fraction) Agree     15 79 15/19 Missing 2 10.5 2/19
Neutral 2 10.5 2/19
Question 2
June 2019
Agree 7 36.8 7/19
Disagree 2 10.5 2/19
Missing 1 5.3 1/19
Neutral 9 47.4 9/19
twildone
Pyrite | Level 9

Hi Richard....thanks for your response. When I set device equal png (goptions device=png;), the calculation of the percentage is correct but the percentage values that I specified for the y axis is not recognized. When I set device equal to actximg, the percentage calculation are different.

RichardDeVen
Barite | Level 11

I do see the problem now, the ACTXIMG bars do not appear to be to scale.

The percentage values show in the hover text is correct though.

 

I think the problem is your expectation more so than the Proc.

 

The vertical axis statement VALUE= option controls the text labels on the major tick marks but DOES NOT DEFINE those tick values.  The tick values must by specified in the ORDER= option.  The ACTXIMG major ticks that you are experiencing are not 0 to 100, but you are labeling them so and therein lies the confusion.

 

Change the AXIS statement to 

 

Axis1 style=1 width=1 minor=none 
  label=(height=9pt font="arial/bold" angle=90  "Percent") 
  value=(height=9pt font="arial" "0%" "10%" "20%" "30%" "40%" "50%" "60%" "70%" "80%" "90%" "100%" )
order = 0 to 100 by 10 /* <---- need this */ ;
twildone
Pyrite | Level 9

Hi Richard....I ran the program and that did the trick....thanks for your help...really appreciate it !!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 873 views
  • 1 like
  • 2 in conversation