Formatting a character variable with a numeric format in a CALL DEFINE statement in the REPORT procedure returns unexpected results


SAS® 9.4 crashes when you have a character variable that is greater than 33 characters in length and you apply a numeric format in the CALL DEFINE statement in PROC REPORT. If the character variable is 32 characters or less and you apply a numeric format in the CALL DEFINE statement in PROC REPORT, the value returned in SAS 9.4 is 0.

In SAS® Viya®, regardless of the length of the character variable, the following message occurs in the SAS log if you apply a numeric format in a CALL DEFINE statement in PROC REPORT. (In addition, you will need to restart SAS Viya.)

The SAS task name is [REPORT  ]
Segmentation Violation
 

Here is an example of PROC REPORT code with a character variable 32 characters or less: 

data check;
length col1 $32; /* Does not crash SAS */
*length col1 $33; /* Crashes SAS */
col1='abc';
run;

proc report data=check;

column col1 ;
define col1 / display '';

compute col1;
call define(1,'format','comma14.0');
endcomp;
run;

To prevent the crash or segmentation violation, ensure the format applied to the character variable is a character format when using CALL DEFINE in PROC REPORT.