BookmarkSubscribeRSS Feed
makset
Obsidian | Level 7

hello 

I have a question. It is possible to transform file A into file B simply and quickly (the files are relatively large) without using loops.

Thank you for your answer.

Best regards.

 

data A;
informat datetime  datetime19.;
input datetime; 
format datetime  datetime19.;
cards;
01NOV2023:00:00:00
02NOV2023:00:00:00
06NOV2023:00:00:00
13NOV2023:00:00:00
17NOV2023:00:00:00
run;


data B;
informat datetime  datetime19.;
input datetime; 
format datetime  datetime19.;
cards;
01NOV2023:00:00:00
01NOV2023:04:00:00
01NOV2023:08:00:00
01NOV2023:12:00:00
01NOV2023:16:00:00
02NOV2023:00:00:00
02NOV2023:04:00:00
02NOV2023:08:00:00
02NOV2023:12:00:00
02NOV2023:16:00:00
06NOV2023:00:00:00
06NOV2023:04:00:00
06NOV2023:08:00:00
06NOV2023:12:00:00
06NOV2023:16:00:00
13NOV2023:00:00:00
13NOV2023:04:00:00
13NOV2023:08:00:00
13NOV2023:12:00:00
13NOV2023:16:00:00
17NOV2023:00:00:00
17NOV2023:04:00:00
17NOV2023:08:00:00
17NOV2023:12:00:00
17NOV2023:16:00:00
run;
1 REPLY 1
Kurt_Bremser
Super User

You can simply do

data b;
set a;
output;
datetime + '04:00't;
output;
datetime + '04:00't;
output;
datetime + '04:00't;
output;
datetime + '04:00't;
output;
run;

But a code with a DO loop will look much cleaner, and be easier to adapt to other requiremments.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1 reply
  • 401 views
  • 1 like
  • 2 in conversation