BookmarkSubscribeRSS Feed
Vaibhav_Kalra
Calcite | Level 5

Hi

I am facing a problem to convert the numeric function to the date part

 

my data  is

 

515
529
540
545
600

In the above 515 means 5:15

529 means 5:29

 

Please advise

 

Thanks

 

 

 

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This "I am facing a problem to convert the numeric function to the date part" doesn't really make sense as the data you give and logic is for time?  I would be cautious about converting just a number like that to a time.  You could simply:

data want;
  input num;
  tmp=strip(put(num,best.));
  tmp=cats(char(tmp,1),":",substr(tmp,2,2));
datalines;
515
529
;
run;

But I suspect thats not really your problem, and your issue includes dates as well.  Perhaps provide fuller information, provide what you have as test data in the form of a datastep and what you want out at the end.

 

Kurt_Bremser
Super User

You need to fix such issues at the point where data enters your SAS environment.

Show how you imported the data into SAS. Just using the correct format there will remove the problem.

Ksharp
Super User
data want;
  input num;
  want=hms(int(num/100),mod(num,100),0);
  format want hhmm5.;
datalines;
515
529
;
run;
Haikuo
Onyx | Level 15

Or:

data want;
  input num;
  want=input(put(num,z4.),hhmmss4.);
  format want hhmm5.;
datalines;
515
529
;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 728 views
  • 0 likes
  • 5 in conversation