Hi there.
I'm trying to create a custom format for a datetime column. The result of aplying the format (label) should be a date value or missing in case the format value is out of range.
My problem is when the value is out of range. Instead of setting it to missing, SAS just returns the value as is, not formated.
The code is the following:
data intervals;
retain fmtname 'myformat';
length start end 8;
informat start end datetime19.;
format start end datetime19.;
set syt10 end=last;
start=lag(datetimevalue);
end=datetimevalue;
label=lag(datevalue);
if _n_^=1 then
output;
if last then do;
start=end;
end='31dec2100:23:59:59'dt;
label=datevalue;
output;
start=.;
end=.;
hlo='O';
label= . ;
output;
end;
keep start end label hlo;
run;
proc format cntlin=intervals;
run;
The procedure runs with no errors.
Let's assume that the first datetime value on the input dataset (syt10) is '31oct2010:00:00:00'dt. Basically, what i need is that every value bellow that datetime is set to missing, and the rest to be set with the datevalue of their corresponding interval. All values in the intervals are well formated, but the ones bellow aren't.
Look at this example output please:
data a;
var='23oct2010:01:01:01'dt;
varf=put(var,myformat.);
put 'format result: ' varf;
var='01nov2010:01:01:01'dt;
varf=put(var,myformat.);
put 'format result: ' varf;
run;
format result: 16E8
format result: 18566
What am i doing wrong here?
Regards in advance.