BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

Hi everyone, I currently have a few tables that have the same exact DATE but different time, just on the minutes.

For example,

All my tables will have the same date, same hour but different minutes.

For example:

 

Table A

2010-Jan-01 01:00:00

2010-Jan-01 03:00:00

2010-Feb-01 01:00:00

2010-Mar-01 01:00:00

 

 

 

Table B

2010-Jan-01 01:44:00

2010-Jan-01 03:44:00

2010-Feb-01 01:44:00

2010-Mar-01 01:44:00

 

 

I want to standardize/manipulate the value in Table B to have the same as Table A. Do take note that my data have more than 100k rows. Furthermore, there are about 100 columns in Table A and another different 100 columns in Table B. All i want to do is to merge table A and B into 1 big table with 200 columns.

 

Is there a way to do so? I personally never had any luck finding similar topics around. The difficulty for me here is the "minutes".

 

I do hope experts can advise on this.

3 REPLIES 3
gamotte
Rhodochrosite | Level 12

Hello,

 

data have;
format a b datetime.;
a=datetime();
b=intnx('minute',intnx('hour',a,0,'b'),44);
run;
imdickson
Quartz | Level 8

Hi gamotte, I havent tried the code yet. Thanks by the way.

 

I have a question. The 44 behind is to substitute 44 with 0. Correct me if I am wrong.

 

However, i have about 15 tables to be merged and every table has different minutes. It could be 44 or 56 or 07.

For this case, what would be the better way?

gamotte
Rhodochrosite | Level 12

My reply illustrated how the minutes in a datetime can be changed.

 

The first part

 

intnx('hour',a,0,'b')

sets the time at the beginning of the hour (modifier 'b' with an increment of 0)

 

Then

 

intnx('minute',...,44);

adds 44 minutes to the time part.

 

For your problem, you can only use the first part and set the minutes to 0 in your different datasets.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 868 views
  • 1 like
  • 2 in conversation