BookmarkSubscribeRSS Feed
abhinayingole
Obsidian | Level 7


Below is the input dataset date.

I wanted output with adding up 40 minutes to the variable 'date' until it is equal or greater than 'final' variable. (wanted to create new 'result' variable for this)

 

but facing error while creating date2 dataset.

could someone please help.


data date (drop = date final);
date = "12Jan21:06:30:00";
final = "12Jan21:22:30:00";

daten = input(date,datetime18.);
finaln = input(final,datetime18.);

dt = finaln;

format daten finaln datetime18.;

run;

%let dt = %eval(1926109800);


data date2;
set date;
do until (result ge &dt.) ;
result = daten + (40*60) ;
output;
end;

format result datetime18.;

run;

 

1 REPLY 1
japelin
Rhodochrosite | Level 12

Since you are just repeatedly adding to daten, the value of result is always constant.
I think you should put the initial value at the beginning and add it to the result.

 

data date2;
  set date;
  result=daten;/* add this statement */
  do until (result ge &dt.) ;
    result = result + (40*60) ;/* change variables from daten to result*/
    output;
  end;
  format result datetime18.;
run;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 539 views
  • 0 likes
  • 2 in conversation