Search code examples
sasproc-report

Row label is being truncated


I have written the following query to extract a list of distinct military status from a SAS table.

proc sql;
create table mil_stat as
    select distinct MILITARY_STAT_sERSS format $MILSTAT. as MILITARY_STATUS, 
        count(*) as TOTAL 
    from FPE
    group by MILITARY_STAT_sERSS;
quit;

I need to add a summary row that shows the total count. I tried to do this in the proc sql statement, but could not figure out how to do it. So, I wrote the following proc report statement to provide the needed row in the report.

PROC REPORT DATA=work.mil_stat;
column MILITARY_STATUS TOTAL;
where MILITARY_STATUS ne '5';
define MILITARY_STATUS / group;
rbreak after / summarize style=[font_weight=bold];
compute MILITARY_STATUS;
    if MILITARY_STATUS ne . then c_MILITARY_STATUS=MILITARY_STATUS;
    else c_MILITARY_STATUS=' ';
    if _break_ = '_RBREAK_' then MILITARY_STATUS = "Grand Total";
endcomp;
run;

The grand total row displays, but 'Grand Total' is truncated to a single character. Result table from proc report statement

Any assistance to be able to display the 'Grand Total' string would be much appreciated.


Solution

  • Looks like MILITARY_STAT_sERSS is only one byte long. And also the format, $MILSTAT., that you are using with that variable does not have any decode for 'G'.

    Try making MILITARY_STATUS long enough to store "Grand Total".

    select MILITARY_STAT_sERSS as MILITARY_STATUS length=11 format=$MILSTAT. 
    ...