SAS Programming

DATA Step, Macro, Functions and more
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.

 

 


undefinedundefinedundefinedundefined
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


undefined
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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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