The `batchresults` action allows for changing the execution mode of a currently running action to batch mode. This is particularly useful for long-running actions, enabling the client to disconnect and retrieve the results later without interrupting the server-side processing. This action requires the UUID of the session where the target action is executing.
| Parameter | Description |
|---|---|
| uuid | Specifies the unique identifier (UUID) of the session where the action to be switched to batch mode is currently running. This parameter is mandatory. |
This step is not directly required for the `batchresults` action itself, as it operates on sessions and actions rather than data. However, to demonstrate its use, we will initiate a long-running action, such as `simple.summary`, on a sample table. The following code creates a sample table `my_table` in the active caslib.
| 1 | PROC CAS; |
| 2 | DATA casuser.my_table; |
| 3 | DO i = 1 to 10000000; |
| 4 | x = rand('UNIFORM'); |
| 5 | y = rand('NORMAL'); |
| 6 | OUTPUT; |
| 7 | END; |
| 8 | RUN; |
| 9 | QUIT; |
This example demonstrates how to start an action in one session, obtain its session UUID, and then use the `batchresults` action from another session to switch the first action to batch mode. This allows the original session to proceed with other tasks or disconnect.
| 1 | /* In Session 1 (long_running_action) */ |
| 2 | PROC CAS; |
| 3 | SESSION casauto name='long_running_action'; |
| 4 | ACTION SIMPLE.summary / TABLE='my_table', async='summary_job'; |
| 5 | PRINT SESSION.sessionId(); |
| 6 | RUN; |
| 7 | |
| 8 | /* In Session 2, after getting the UUID from Session 1 */ |
| 9 | PROC CAS; |
| 10 | SESSION.batchresults / uuid='uuid-from-session-1'; |
| 11 | RUN; |
This detailed example illustrates the full lifecycle: 1. Start a CAS session and a potentially long-running action asynchronously. 2. Retrieve the session's UUID. 3. In a separate session, use the `batchresults` action to detach from the running job. 4. Later, reconnect or use another session to check the status and fetch the results of the completed batch job.
| 1 | /* Step 1: Start the asynchronous action in Session A */ |
| 2 | cas session_a; |
| 3 | PROC CAS; |
| 4 | SESSION session_a name='session_a'; |
| 5 | ACTION SIMPLE.summary RESULT=summary_job / TABLE='my_table', async='my_summary_job'; |
| 6 | PRINT 'Session A UUID: ' || SESSION.sessionId(); |
| 7 | RUN; |
| 8 | |
| 9 | /* Step 2: In a separate SAS session (Session B), use the UUID from Session A */ |
| 10 | cas session_b; |
| 11 | PROC CAS; |
| 12 | SESSION session_b name='session_b'; |
| 13 | /* Replace 'uuid-from-session-a' with the actual UUID printed in Step 1 */ |
| 14 | ACTION SESSION.batchresults / uuid='uuid-from-session-a'; |
| 15 | RUN; |
| 16 | |
| 17 | /* Step 3: Later, in any session, check the job status and fetch results */ |
| 18 | PROC CAS; |
| 19 | ACTION SESSION.actionstatus / name='my_summary_job'; |
| 20 | ACTION SESSION.fetchresult / name='my_summary_job'; |
| 21 | RUN; |
A marketing analyst needs to run a complex customer segmentation analysis (using the `fastknn` action) which takes a considerable amount of time. They want to start the job, dis...
A bioinformatics research institute is processing massive genomic datasets. A researcher initiates a heavy aggregation (`simple.summary`) on a table with hundreds of millions of...
A financial institution's QA team is validating the stability of their CAS environment. They need to ensure that the `batchresults` action behaves predictably and provides clear...