?>Array ( [id] => 16 )
Scénario de test & Cas d'usage
Se define un conjunto de acciones 'marketingScoring' con una acción para calcular un score simple. Luego, se guarda en una tabla CAS llamada 'marketingActionSetRepo' para su posterior reutilización.
| 1 | PROC CAS; |
| 2 | BUILTINS.defineActionSet / |
| 3 | name='marketingScoring', |
| 4 | actions={{ |
| 5 | name='calculateScore', |
| 6 | definition=' |
| 7 | table.save / table={name="scored_customers", replace=true}, |
| 8 | casout={name="scored_customers_out", replace=true}, |
| 9 | code="DATA scored_customers_out; SET scored_customers; score = annual_income / 10000 * customer_age / 10; RUN;"; |
| 10 | print \"INFO: Scoring completado.\";' |
| 11 | }}; |
| 12 | RUN; |
| 13 | BUILTINS.actionSetToTable / |
| 14 | name='marketingScoring', |
| 15 | TABLE={name='marketingActionSetRepo', caslib='CASUSER', replace=true}; |
| 16 | RUN; |
| 17 | /* Simular datos de clientes para el test */ |
| 18 | DATA CASUSER.customers_to_score; |
| 19 | DO customer_id = 1 to 100; |
| 20 | annual_income = 30000 + rand('INTEGER', 1, 70000); |
| 21 | customer_age = 20 + rand('INTEGER', 1, 45); |
| 22 | OUTPUT; |
| 23 | END; |
| 24 | RUN; |
| 25 | QUIT; |
| 1 | PROC CAS; |
| 2 | /* Simula una nueva sesión donde 'marketingScoring' no existe */ |
| 3 | BUILTINS.actionSetFromTable / |
| 4 | TABLE={name='marketingActionSetRepo', caslib='CASUSER'}; |
| 5 | RUN; |
| 6 | QUIT; |
| 1 | PROC CAS; |
| 2 | BUILTINS.actionSetInfo / name='marketingScoring'; |
| 3 | RUN; |
| 4 | QUIT; |
| 1 | PROC CAS; |
| 2 | /* Cargar los datos de clientes a la sesión */ |
| 3 | load DATA=CASUSER.customers_to_score; |
| 4 | RUN; |
| 5 | /* Ejecutar la acción restaurada */ |
| 6 | marketingScoring.calculateScore / TABLE={name='customers_to_score'}; |
| 7 | RUN; |
| 8 | /* Verificar el resultado */ |
| 9 | TABLE.fetch / TABLE={name='scored_customers_out', to=5}; |
| 10 | RUN; |
| 11 | QUIT; |
El conjunto de acciones 'marketingScoring' se restaura con éxito. La acción 'calculateScore' se ejecuta sobre la tabla 'customers_to_score', creando una nueva tabla 'scored_customers_out' con la columna 'score' calculada. La llamada a 'actionSetInfo' y 'table.fetch' confirman que el conjunto de acciones y sus resultados son correctos, validando la reutilización de la lógica de negocio entre sesiones.