|
On Mon, 24 Nov 2003 12:11:52 -0600, Rob Rohrbough <Rob@ROHRBOUGH-
SYSTEMS.COM> wrote:
>In my wildest dreams, I would like to do the following:
>
>data _null_;
> x = '1120';
> y = input(x, hhmm4.);
> put x= y=;
>run;
>
>SAS8 does not appear to have a four-character time format to input hours
and
>minutes, as in "hhmm4.", above. Am I wrong? There seems to be no "HHMM"
>format, and neither time4. nor time5. work on a value like "1120".
>
>Any suggestions other than cracking the silly thing myself? (like
>translating it to "11:20")
>
>TIA,
>
>Rob
>
>
Would you consider a macro~function~ like
y= %time4(var) ;
where that macro %time4 does the tedious work of generating
the substringing and inputting..... like
18 %macro time4( var );
19 input( substr(&var,1,2) ||':'|| substr(&var,3,2), time5. )
20 %mend time4 ;
21 data demo;
22 str = '1120';
23 time= %time4( str );
24 put (_all_)(=) time= time. ;
25 run;
str=1120 time=40800 time=11:20:00
|