Some functions truncate strings in PROC SQL:
data TEST;
length X $300;
X=repeat('X',299);
run;
proc sql;
create table WANT as %* Var Len;
select trim(X) as TRIM %* 300;
, translate(X,'a','b') as TRANSLATE %* 300;
, scan(X,1) as SCAN %* 300;
, left(X) as LEFT %* 300;
, prxchange('s/a/b/',1,X) as PRXCHANGE %* 200;
, cat(X) as CAT %* 200;
, case when 1 then cat(X) end as CASE %* 200;
from TEST;
quit;
But this can be fixed in some cases by forcing the variabel length:
proc sql;
create table WANT as %* Str Len;
select trim(X) as TRIM length=300 %* 300;
, translate(X,'a','b') as TRANSLATE length=300 %* 300;
, scan(X,1) as SCAN length=300 %* 300;
, left(X) as LEFT length=300 %* 300;
, prxchange('s/a/b/',1,X) as PRXCHANGE length=300 %* 300;
, cat(X) as CAT length=300 %* 300;
, quote(X) as QUOTE length=302 %* 302;
, case when 1 then quote(X) end as CASE length=302 %* 0 <==;
from TEST;
quit;
The case statement however does not pass on the defined length to the executed function. It should.