The SIMSYSTEM Procedure
Example 22.3 Simulating Portfolio Values
This example demonstrates how you can use PROC SIMSYSTEM to perform an experimental simulation over a grid of potential distributions. The procedure plays two different roles in this application: screening the shapes of potential distributions and simulating samples from selected distributions. Other SAS tools (the DATA step, PROC SUMMARY, and PROC RSREG) are used to complete and analyze the simulation.
You are interested in studying the likely performance over the next 30 years of a $1,000,000 portfolio that is managed to track the performance of the S&P 500 stock index. Of course, key information that you are missing is the future performance of the S&P 500, but you can simulate it for a variety of potential distributions.
Your first question is, What are the potential shapes for the true distribution of total annual returns of the S&P 500? You can use PROC SIMSYSTEM to get an idea of this, by specifying several potential values for skewness and kurtosis that seem feasible according to historical data and reviewing the density plots for them, as shown in the following code:
proc simsystem system=johnson;
momentgrid Skewness = -1.0 -0.5 0.0
Kurtosis = 2.3 3.1 3.9;
run;
The table of parameters for these distributions, shown in Figure 18, indicates that they are mostly of the bounded type. Also, as you can see in Output 22.3.1, most of the densities seem reasonable, except for the first one, with the lowest values of both skewness and kurtosis.
Figure 18: Parameters of Representative Distributions for S&P 500 Returns
| Parameters for Johnson Distributions | |||||||
|---|---|---|---|---|---|---|---|
| Skewness | Kurtosis | Family | Delta | Gamma | Shift | Scale | |
| 1 | -1 | 2.300 | SB(2) | 0.190 | 0.627 | 0.739 | -2.674 |
| 2 | -1 | 3.100 | SB(1) | 0.647 | 0.931 | 1.146 | -4.311 |
| 3 | -1 | 3.900 | SB(1) | 1.259 | 1.779 | 1.730 | -7.785 |
| 4 | -0.500 | 2.300 | SB(1) | 0.799 | 0.565 | 1.598 | -4.346 |
| 5 | -0.500 | 3.100 | SB(1) | 2.109 | 1.917 | 3.109 | -10.49 |
| 6 | -0.500 | 3.900 | SU | 2.931 | -1.378 | 1.276 | -2.469 |
| 7 | 0 | 2.300 | SB(1) | 1.225 | 85E-16 | -2.796 | 5.592 |
| 8 | 0 | 3.100 | SU | 6.441 | 0 | 0 | 6.363 |
| 9 | 0 | 3.900 | SU | 2.417 | 0 | 0 | 2.213 |
Output 22.3.1: Representative Densities for S&P 500 Returns


The extreme density in Output 22.3.1 is omitted by a PROC DS2 step after the PROC SIMSYSTEM code, as shown in the following statements. The grid discussed earlier is expanded with typical values for the mean and standard deviation of annual S&P 500 returns. The code creates, for each set of moment values, 1,000 replicates of potential sequences of N=30 years of total annual returns, using the Johnson system of distributions. You will use these potential sequences of returns to explore the success rate of your portfolio for each distribution, as defined by the moments.
proc simsystem n=30 system=johnson seed=12345 noprint nrep=1000;
momentgrid
Mean = 7.5 12.0 16.5
StdDev = 17.0 20.0 23.0
Skewness = -1.0 -0.5 0.0
Kurtosis = 2.3 3.1 3.9;
output out=mycas.Sim_raw Mean=Mean Std=StdDev;
run;
proc ds2 sessref=mysess;
data Sim / overwrite=yes;
rename Variate=AnnualReturn;
method run();
set Sim_raw;
if ^((Skewness = -1) & (Kurtosis = 2.3)) then output;
end;
enddata;
run;
quit;
The resulting data table has over 2,000,000 observations. These observations will be processed in groups defined by the simulation index SimIndex and the replicate number Rep, each group being a potential sequence of returns for the hypothetical 30 years of interest. The value of your portfolio for any particular sequence of returns is adjusted annually by the simulated return and also by a fixed withdrawal of $40,000 per year. The sequence is successful for your portfolio if its value never falls below $0. The following PROC DS2 code evaluates the success of each simulated sequence of 30 returns, using a thread block to process different replicates in parallel. A subsequent PROC MDSUMMARY step computes the mean of these 0/1 success values, which is thus the observed success rate for each set of moment values that are defined by the MOMENTGRID statement.
%let Start = 1000000;
%let Withdraw = 40000;
proc ds2 sessref=mysess;
thread Success_thd / overwrite=yes;
dcl double Value minVal;
dcl int Success;
retain Value minVal;
keep SimIndex Mean StdDev Skewness Kurtosis Rep Success;
method run();
set Sim; /*being parallelized*/
by SimIndex Rep;
/*BY statement takes the BY-groups as batches in threads*/
if FIRST.Rep then do; /* First year in a sequence: */
Value = 1000000; /* Initialize the portfolio */
minVal = Value; /* value. */
end;
/*
/ The value at the end of the year is the sum of the
/ original value and the annual return, minus the amount
/ withdrawn.
/---------------------------------------------------------*/
if Value then do;
Value = Value + (AnnualReturn/100)*Value - 40000;
minVal = min(minVal, Value);
end;
if LAST.Rep then do; /* Last year in a sequence: */
Success = (minVal > 0); /* Evaluate success and */
output; /* output. */
end;
end;
endthread;
data Success / overwrite=yes;
dcl thread Success_thd Success_thd_instance;
method run();
set from Success_thd_instance threads=1;
end;
enddata;
run;
quit;
proc mdsummary data=mycas.Success;
groupby Mean StdDev Skewness Kurtosis SimIndex;
var Success;
output out=mycas.ProbSuccess;
run;
proc cas;
session mysess;
table.alterTable /
name="ProbSuccess"
columns={{name="_Mean_" rename="ProbSuccess" label=""}};
quit;
Finally, you use PROC RSREG, as in the following statements, to apply response surface analysis methods to the simulated success rates. PROC RSREG fits a quadratic function to these values and plots the predicted surfaces.
proc rsreg data=mycas.ProbSuccess plots=contour(nodesign);
model ProbSuccess = Mean StdDev Skewness Kurtosis;
ods select FactorANOVA Contour;
run;
Selected PROC RSREG results are shown in Figure 19 and Output 22.3.2. The ANOVA for individual factors shows that although the mean rate of return is the most influential factor in portfolio success, all four moments of the return distribution have some effect. In the plots of predicted success rates, you can see that a $40,000 withdrawal gives your portfolio about a 95% probability of success in the center of the experimental region, near the historical estimates for the moments of the return distribution. This is encouraging, but the predicted probability of success drops off precipitously as the moments of the return distribution change.
Figure 19: Response Surface Analysis of Simulated S&P 500 Returns
| Factor | DF | Sum of Squares | Mean Square | F Value | Pr > F | Label |
|---|---|---|---|---|---|---|
| Mean | 5 | 0.614429 | 0.122886 | 1366.43 | <.0001 | Mean |
| StdDev | 5 | 0.165644 | 0.033129 | 368.38 | <.0001 | Standard Deviation |
| Skewness | 5 | 0.011151 | 0.002230 | 24.80 | <.0001 | Skewness |
| Kurtosis | 5 | 0.002208 | 0.000442 | 4.91 | 0.0008 | Kurtosis |
Output 22.3.2: Predicted S&P 500 Returns

