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?