Scénario de test & Cas d'usage
Precise calculation of percentiles and quantiles.
Discover all actions of percentileCreation of a simulated dataset representing daily stock returns for various stocks across three market sectors: Technology, Healthcare, and Financials.
| 1 | DATA casuser.stock_returns; |
| 2 | call streaminit(123); |
| 3 | DO sector_id = 1 to 3; |
| 4 | IF sector_id = 1 THEN sector = 'Technology'; |
| 5 | ELSE IF sector_id = 2 THEN sector = 'Healthcare'; |
| 6 | ELSE sector = 'Financials'; |
| 7 | DO stock_id = 1 to 50; |
| 8 | DO day = 1 to 252; /* Trading days in a year */ |
| 9 | IF sector = 'Technology' THEN daily_return = (rand('NORMAL', 0.05, 0.8)); |
| 10 | ELSE IF sector = 'Healthcare' THEN daily_return = (rand('NORMAL', 0.02, 0.4)); |
| 11 | ELSE daily_return = (rand('NORMAL', 0.03, 0.6)); |
| 12 | OUTPUT; |
| 13 | END; |
| 14 | END; |
| 15 | END; |
| 16 | keep sector stock_id day daily_return; |
| 17 | RUN; |
| 1 | |
| 2 | PROC CASUTIL; |
| 3 | load |
| 4 | DATA=casuser.stock_returns outcaslib='casuser' casout='stock_returns' replace; |
| 5 | QUIT; |
| 6 |
| 1 | PROC CAS; |
| 2 | percentile.boxPlot / |
| 3 | TABLE={name='stock_returns', groupBy={'sector'}}, |
| 4 | inputs={{name='daily_return'}}; |
| 5 | RUN; |
The action returns a result table containing distinct box plot statistics (Q1, median, Q3, min, max) for the 'daily_return' variable for each market sector. The 'Technology' sector is expected to show a wider interquartile range and higher whisker values, confirming higher volatility compared to 'Healthcare'.