Reputation: 323
I am working is SAS guide 7.1 and I need to run a process with proc sql but don't work well, though it work well with step data. The folliwing code replicate the issue
data test;
input date;
datalines;
20140101
;
run;
data test2;
set test;
date1 = input(compress(date),yymmdd10.);
format date1 date9.;
run;
Code with proc sql:
proc sql;
create table test3 as select
*,
input(compress(date),yymmdd10.) format date9. as date1
from test;
quit;
The error message:
Function COMPRESS requires a character expression as argument 1. Why COMPRESS operates in a different way with both step data and proc sql?
Upvotes: 0
Views: 2728
Reputation: 51611
The compress()
function is operating the same way.
But PROC SQL
does not do automatic type conversion the way that a data step will. Look at the notes from your data step.
207 data test2;
208 set test;
209 date1 = input(compress(date),yymmdd10.);
210 format date1 date9.;
211 run;
NOTE: Numeric values have been converted to character values at the places given by:
(Line):(Column).
209:24
Just tell SAS explicitly that you want to convert the number 20,140,101 to the string '20140101' and then convert that string into a date value.
input(put(date,z8.),yymmdd8.)
Upvotes: 2