Type : CREATION_INTERNE
Los ejemplos utilizan datos generados (datalines) para asegurar la autonomía y la reproducibilidad.
| 1 | DATA my_data; |
| 2 | INPUT ID $ Name $ Age Score; |
| 3 | DATALINES; |
| 4 | 001 John 30 95 |
| 5 | 002 Jane 24 88 |
| 6 | 003 Mike . 72 |
| 7 | 004 Jane 24 88 |
| 8 | 005 Chris 45 60 |
| 9 | 006 John 30 95 |
| 10 | 007 Sarah 29 . |
| 11 | ; |
| 12 | RUN; |
| 13 | |
| 14 | PROC DATAMETRICS DATA=my_data out=my_results; |
| 15 | RUN; |
| 16 | |
| 17 | PROC PRINT DATA=my_results; |
| 18 | title 'Resultados Básicos de PROC DATAMETRICS'; |
| 19 | RUN; |
| 1 | DATA employees; |
| 2 | INPUT EmployeeID Name $ Department $ Salary DateOfHire:yymmdd10.; |
| 3 | FORMAT DateOfHire yymmdd10.; |
| 4 | DATALINES; |
| 5 | 101 Alice Sales 60000 2020-01-15 |
| 6 | 102 Bob Marketing 75000 2019-03-22 |
| 7 | 103 Alice Sales 60000 2020-01-15 |
| 8 | 104 Charlie IT 80000 2021-07-01 |
| 9 | 105 David Sales 62000 2020-01-15 |
| 10 | ; |
| 11 | RUN; |
| 12 | |
| 13 | PROC DATAMETRICS DATA=employees out=employee_metrics; |
| 14 | variables EmployeeID Name Department Salary; |
| 15 | OUTPUT metric=ALL; |
| 16 | RUN; |
| 17 | |
| 18 | PROC PRINT DATA=employee_metrics; |
| 19 | title 'Métricas de Calidad para Variables Específicas'; |
| 20 | RUN; |
| 1 | DATA transactions; |
| 2 | INPUT TransactionID CustomerID ProductID $ Quantity Price Date:yymmdd10.; |
| 3 | FORMAT Date yymmdd10.; |
| 4 | DATALINES; |
| 5 | T001 C001 P001 2 15.50 2023-01-05 |
| 6 | T002 C002 P002 1 10.00 2023-01-05 |
| 7 | T003 C001 P001 2 15.50 2023-01-05 |
| 8 | T004 C003 P003 3 25.75 2023-01-06 |
| 9 | T005 C001 P001 2 15.50 2023-01-05 |
| 10 | ; |
| 11 | RUN; |
| 12 | |
| 13 | PROC DATAMETRICS DATA=transactions out=transaction_summary; |
| 14 | identities TransactionID CustomerID ProductID; |
| 15 | variables Quantity Price; |
| 16 | OUTPUT metric=ALL outall; |
| 17 | RUN; |
| 18 | |
| 19 | PROC PRINT DATA=transaction_summary; |
| 20 | title 'Análisis Avanzado de Métricas e Identidades de Transacciones'; |
| 21 | RUN; |
| 1 | /* Connexion à la session CAS et chargement des données */ |
| 2 | cas; |
| 3 | LIBNAME mycas cas; |
| 4 | |
| 5 | DATA mycas.sales_data; |
| 6 | INPUT SaleID $ Region $ Amount Date:yymmdd10.; |
| 7 | FORMAT Date yymmdd10.; |
| 8 | DATALINES; |
| 9 | S001 East 1200.50 2024-01-10 |
| 10 | S002 West 850.25 2024-01-11 |
| 11 | S003 North 1500.00 2024-01-10 |
| 12 | S004 South 980.75 2024-01-12 |
| 13 | S005 East . 1000.00 2024-01-13 |
| 14 | ; |
| 15 | RUN; |
| 16 | |
| 17 | /* Exécution de PROC DATAMETRICS sur CAS */ |
| 18 | PROC DATAMETRICS DATA=mycas.sales_data out=mycas.sales_metrics; |
| 19 | variables SaleID Region Amount Date; |
| 20 | OUTPUT metric=ALL; |
| 21 | RUN; |
| 22 | |
| 23 | /* Affichage des résultats depuis CAS */ |
| 24 | PROC PRINT DATA=mycas.sales_metrics; |
| 25 | title 'Métricas de Calidad de los Datos de Ventas (CAS)'; |
| 26 | RUN; |
| 27 | |
| 28 | /* Arrêt de la session CAS */ |
| 29 | cas term; |