03-28-2016 10:50 AM - last edited on 03-28-2016 12:10 PM by Reeza
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.
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;
03-28-2016 11:57 AM
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.
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.
03-28-2016 10:06 PM
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.
04-05-2016 10:44 AM
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;