BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alam_ather
Calcite | Level 5

Dear All - I have been trying to write a query in SAS EG in which I need to add the time difference of 30 minutes as per the following date and time format:

1141013222329

The above format means 13OCT2014 22:22:39

Now I want to extract processing done after 30 minutes of time difference.

and the desired result should be 13OCT2014 22:52

Can somebody help me to get this thing done.

thanks

Ather

1 ACCEPTED SOLUTION

Accepted Solutions
JPM
Calcite | Level 5 JPM
Calcite | Level 5

Hi.

Your date time does not mean 13OCT2014 22:22:39, it means 13OCT2014 22:23:39.

The following, while far from elegant, will get the job done, as long as the curious leading "1" doesn't change.

data test;

dtinput=put(1141013222329,best13.);

dtstr1=substr(dtinput,2,6) ||" "|| substr(dtinput,8,2) ||":"|| substr(dtinput,10,2) || ":" || substr(dtinput,12,2);

dtnumeric=input(dtstr1(anydtdtm19.);

processInterval=intnx("dtminute",dtnumeric,30,"s");

format processInterval datetime;

run;

*Result processInterval = 13Oct14:22:53:29  ;

Good luck in your project.

-Joel.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

First of all you need to provide a rule which digit positions in your original value correspond to day, month, year, hours, minutes and seconds.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

If its a datetime value (and I am in meeting so cant check), then you can use intck on the time part to increment 30 minutes and then use that with the datepart.

JPM
Calcite | Level 5 JPM
Calcite | Level 5

Hi.

Your date time does not mean 13OCT2014 22:22:39, it means 13OCT2014 22:23:39.

The following, while far from elegant, will get the job done, as long as the curious leading "1" doesn't change.

data test;

dtinput=put(1141013222329,best13.);

dtstr1=substr(dtinput,2,6) ||" "|| substr(dtinput,8,2) ||":"|| substr(dtinput,10,2) || ":" || substr(dtinput,12,2);

dtnumeric=input(dtstr1(anydtdtm19.);

processInterval=intnx("dtminute",dtnumeric,30,"s");

format processInterval datetime;

run;

*Result processInterval = 13Oct14:22:53:29  ;

Good luck in your project.

-Joel.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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