Below is a sample dataset and code that I am running. If you run this you will see the legend says Fail, 0,1. I would like it to show the total of passes and fails. So it would have pass 9, fail 1. Any help will be appreciated. Also, I'm not experienced using graphs, so any other suggestions or pointers are welcome.
edit* Also, I am getting the following warnings when I go to my full datasset:
WARNING: The intervals on the axis labeled "REPORTING_MONTH" are not evenly spaced.
WARNING: Some INSIDE= labels were not drawn due to space limitations.
Thank You,
data data;
infile cards dsd;
input reporting_month$ rule$ fail_total column$ description$ pass fail;
cards;
20151031,0001,0,BHC_NAME,No Nulls,1,0
20151130,0001,0,BHC_NAME,No Nulls,1,0
20151231,0001,0,BHC_NAME,No Nulls,1,0
20151031,0002,0,ID_RSSD,No Nulls,1,0
20151130,0002,0,ID_RSSD,No Nulls,1,0
20151231,0002,0,ID_RSSD,No Nulls,1,0
20151031,0003,0,PORTFOLIO_ID,ContentCheck=USOthCons,1,0
20151130,0003,0,PORTFOLIO_ID,ContentCheck=USOthCons,1,0
20151231,0003,0,PORTFOLIO_ID,ContentCheck=USOthCons,1,0
20151031,0004,0,REPORTING_MONTH,ContentCheck=QTR,1,0
20151130,0004,0,REPORTING_MONTH,ContentCheck=QTR,1,0
20151231,0004,0,REPORTING_MONTH,ContentCheck=QTR,1,0
20151031,0005,0,SEGMENT_ID,No Nulls,1,0
20151130,0005,0,SEGMENT_ID,No Nulls,1,0
20151231,0005,0,SEGMENT_ID,No Nulls,1,0
20151031,0006,0,PRODUCT_TYPE,ContentCheck=01-05,1,0
20151130,0006,0,PRODUCT_TYPE,ContentCheck=01-05,1,0
20151231,0006,0,PRODUCT_TYPE,ContentCheck=01-05,1,0
20151031,0007,0,PRODUCT_TYPE,Comapre01=Secured/Revolving,1,0
20151130,0007,0,PRODUCT_TYPE,Comapre01=Secured/Revolving,1,0
20151231,0007,0,PRODUCT_TYPE,Comapre01=Secured/Revolving,1,0
20151031,0008,0,PRODUCT_TYPE,Compare02=Secured/Installment,1,0
20151130,0008,0,PRODUCT_TYPE,Compare02=Secured/Installment,1,0
20151231,0008,0,PRODUCT_TYPE,Compare02=Secured/Installment,1,0
20151031,0009,0,PRODUCT_TYPE,Compare03=Unsecured/Revolving,1,0
20151130,0009,0,PRODUCT_TYPE,Compare03=Unsecured/Revolving,1,0
20151231,0009,0,PRODUCT_TYPE,Compare03=Unsecured/Revolving,1,0
20151031,0010,1,PRODUCT_TYPE,Compare04=Unsecured/Installment,0,1
20151130,0010,1,PRODUCT_TYPE,Compare04=Unsecured/Installment,0,1
20151231,0010,1,PRODUCT_TYPE,Compare04=Unsecured/Installment,0,1
;run;
proc gchart data=data;
vbar reporting_month / discrete subgroup=fail
/*group=pass*/ /*g100 nozero */
/*sum=fail*/ /*type=sum */
inside=freq width=10;*
gaxis=axis1 raxis=axis2;*
legend=legend1;
run;
quit;
The warnings about unevenly spaced bars are because the intervals are not even. The procedure is looking at 1031, 1130 and 1231 which are not the same. Dates generally aren't because the number of days in the months vary. You can ignore that message. Or for your purpose only read the year and month if the warning bothers you.
Second hint:
Post code in the box using the "run" symbol above. Your code as posted contained several artifacts, likely from various forum and your content interactions such that it would not run without editing to remove non-printable characters in the middle of the data and at the end of lines in the graph.
The limited table ability of Gchart isn't going to get statistics by subgroup. You would have to use something to create an annotate data set to display.
Yes it is a shame these messages are warnings, they should be notes.
If you don't want to annotate, an easier way is to create a footnote with the wanted text by precomputing the figures and using macro variables.
And your data is very dirty as mentionned. Please avoid this.
I'm not sure what you mean by 'dirty'. Do you mean because it's monthly, or because of the way the pass/fail is set up. I'm not sure how to clean it up.
Are you really wanting the legend to show the totals for just 1 bar (9 and 1)? Or are you wanting the legend to show the grand total of all the bars? (27 and 3)? Or maybe you just want the legend to show a more descriptive text value, rather than the numeric 1 and 0 values??
If the latter (which is what I'd recommend), then here's how to do it ... you would create a user-defined-format, so that the 1 and 0 show up as the desired text "Fail" and "Pass" ...
legend1 label=(position=top 'Totals:') value=(justify=left) order=descending
position=(right middle) across=1 shape=bar(.15in,.15in) offset=(-15,0);
proc format;
value p_f_fmt
0 = "Pass"
1 = "Fail"
;
run;
proc gchart data=data;
format fail p_f_fmt.;
vbar reporting_month / discrete subgroup=fail legend=legend1;
run;
quit;
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!
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.