DATA Step, Macro, Functions and more

Time informat

Reply
Occasional Contributor
Posts: 15

Time informat

I tried to use STIMERw. and TIMEw. informats but am getting error

 

Kindly go through the attached doc for the refff.

 

 


jhwXT0MCeS_2JibG34NgiBPzkrmRm3SLPQ.pngLcxOTxM6TL8aOd_WoJMTXijzsvBv7lFOPA.pngtDaidsz-TXPDzqHBlPqgzKnu420yVxZpJQ.pngwhere to get all wps out put window.PNG
Super User
Super User
Posts: 7,945

Re: Time informat

Post test data and code as text in the code window ({i} above the post or the SAS symbol), this isn't a game of picture hunt!

 

As for your first question, I know of no format called stimer, which is probably why it isn't recognised.  Unless its a very new one its invalid, so where did you get the idea that it was?

 

The timeX.D variable should work, although what do you expect from length 7?  

Time5. = HH:MM

Time8. = HH:MMSmiley FrustratedS

As for the last picture I have no idea what you mean.

Valued Guide
Posts: 2,177

Re: Time informat

[ Edited ]

@mrinmoywhen hunting for a suitable informat, use the format hunter - as described in paper at http://support.sas.com/resources/papers/proceedings14/1744-2014.pdf

 

%LET  string=    23:45.0 ; * test this ;
%LET require= "0:23:45"t ; * result wanted ;
DATA time_test ; 
 RETAIN string "&string" /* value to be tested */
        Want1   &require /* result wanted */
 ; 
 SET sashelp.vformat ; * list of all formats ; 
 WHERE fmtType = 'I' ;           * only INFORMAT rows ;
 WHERE ALSO fmtName ne: '$' ;    * not character formats;
 
 inValue = INPUTN( string, fmtName, length(string) ) ; * perform test ;
 
 if _error_ then do;
    _error_ = 0 ; * avoiding variable dump in the SAS log ;
    Delete ;
 End ;
 if invalue = want1 ; * now check value returned ;
 PUT "&string " inValue= invalue dateTime. +1 fmtname= ;
RUN ;

The results indicate success for  hhmmss. as well as stimer. So if your SAS release doesn't support informat stimer. you might have success with informat HHMMSS.

 

Super User
Posts: 7,778

Re: Time informat

Which SAS version are you using? The STIMER informat has been around since at least 9.2:

data test;
input timeval :stimer8.;
format timeval time8.;
cards;
22
22:23
15:23:27
;
run;

proc print data=test noobs;
run;

Result:

 timeval

 0:00:22
 0:22:23
15:23:27

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 15

Re: Time informat

Posted in reply to KurtBremser

data X;

infile " file location .dat";

input canoe $ @ 'school:' school $ @ 'time:' racetime :time7.;

run;

 

Kindly have a look at the attach fiel for the log out put


YPuAS_WQ7eogx6uQzZgc6HUcH9TcCYj8-w.png
Super User
Posts: 7,778

Re: Time informat

Please post the contents of your text file as text (copy/paste to a {i} subwindow). I'm not typing test data manually from a picture.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 11,343

Re: Time informat

From the documentaion:

TIMEw. Informat



Reads hours, minutes, and seconds in the form hh:mm:ss.ss

 

So TIME would fail because you do not have an hour component.

 

Which version of SAS are you running? STIMER should be available if SAS 9.2 or later.

Valued Guide
Posts: 2,177

Re: Time informat

Hi @ mrinmoy

I see you are using WPS

That might explain the absence of the STIMER informat

If the HHMMSS informat doesn't work either, you might need to speak to the producers of WPS to see if they can add these informats, or provide you the support you need in some other way

all the best

 

 

 

 

Ask a Question
Discussion stats
  • 7 replies
  • 211 views
  • 2 likes
  • 5 in conversation