BookmarkSubscribeRSS Feed
Steelers_In_DC
Barite | Level 11

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; 
5 REPLIES 5
ballardw
Super User

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.

 

ChrisNZ
Tourmaline | Level 20

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.

Steelers_In_DC
Barite | Level 11

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. 

ChrisNZ
Tourmaline | Level 20
Paste it in sas and try to run it. It contains non printable characters.
GraphGuy
Meteorite | Level 14

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; 

bar_legend.png

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 5 replies
  • 1405 views
  • 0 likes
  • 4 in conversation