0

I have a routine in SAS that runs intraday, periodically updating data in table A. I would like to identify the batch of data by the timestamp column and increment it with each data update throughout the day.
Example: First routine of the day - entry data:
data

id column_a timestamp
1 Orange Bank 07Apr2025 00:05:15
2 Market Bank 07Apr2025 00:05:15
3 Orange Coins 07Apr2025 00:05:15

Recording output in table A:

id column_a timestamp batch
1 Orange Bank 07Apr2025 00:05:15 1
2 Market Bank 07Apr2025 00:05:15 1
3 Orange Coins 07Apr2025 00:05:15 1

Second routine of the day:
data

id column_a timestamp
4 Black Bank 07Apr2025 00:25:48
5 Joseph House 07Apr2025 00:25:48
6 Blank Mall 07Apr2025 00:25:48

Doing append in table A increasing 1 in batch column by timestamp:

id column_a timestamp batch
4 Black Bank 07Apr2025 00:25:48 2
5 Joseph House 07Apr2025 00:25:48 2
6 Blank Mall 07Apr2025 00:25:48 2

Consolidated table A:

id column_a timestamp batch
1 Orange Bank 07Apr2025 00:05:15 1
2 Market Bank 07Apr2025 00:05:15 1
3 Orange Coins 07Apr2025 00:05:15 1
4 Black Bank 07Apr2025 00:25:48 2
5 Joseph House 07Apr2025 00:25:48 2
6 Blank Mall 07Apr2025 00:25:48 2

And so the routine continues throughout the day, increasing the batch number with each new batch of data... What is the best way to do this?

1 Answer 1

0

You can compute the batch number apriori and apply it to the batch data.

select sum(max(batch),1) into :next_batch_number trimmed from <target> where datepart(timestamp) = today() ;

data batch ;
  set <mydata> ;
  batch = &next_batch_number ;
  timestamp = datetime() ;
run ;

proc append base=<target> data=batch ;
run ;  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.