BookmarkSubscribeRSS Feed
mrinmoy
Obsidian | Level 7

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
7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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:MM:SS

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

Peter_C
Rhodochrosite | Level 12

@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.

 

Kurt_Bremser
Super User

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

 

mrinmoy
Obsidian | Level 7

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
Kurt_Bremser
Super User

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.

ballardw
Super User

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.

Peter_C
Rhodochrosite | Level 12

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

 

 

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1611 views
  • 2 likes
  • 5 in conversation