VaR Estimation

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: copex01.sas
 Description: Example program from SAS/ETS User's Guide,
              The COPULA Procedure
       Title: VaR Estimation
     Product: SAS/ETS Software
        Keys: copula joint distribution
        PROC: COPULA
       Notes:

--------------------------------------------------------------*/

ods graphics on;

data returns;
   format date MMDDYY10.;
   input date:MMDDYY10. price_ibm price_msft price_bp price_ko price_duk;
   ret_msft = price_msft/lag(price_msft)-1;
   ret_ko   = price_ko/lag(price_ko)-1;
   ret_ibm  = price_ibm/lag(price_ibm)-1;
   ret_duk  = price_duk/lag(price_duk)-1;
   ret_bp   = price_bp/lag(price_bp)-1;
   if ret_msft ^= .;
   keep date ret_ibm ret_msft ret_bp ret_ko ret_duk;
datalines;
01/02/2008    99.91   33.48   62.78   56.91   17.13
01/03/2008   100.11   33.62   63.98   57.50   17.19
01/04/2008    96.52   32.68   63.05   57.61   17.18
01/07/2008    95.49   32.90   64.18   58.97   17.62
01/08/2008    93.14   31.80   63.15   59.22   17.57
01/09/2008    93.82   32.74   61.44   60.80   17.76
01/10/2008    95.36   32.64   61.17   61.07   17.73
01/11/2008    93.21   32.24   60.04   59.40   17.51
01/14/2008    98.23   32.69   60.11   59.90   17.57
01/15/2008    97.18   32.32   57.65   59.25   17.27
01/16/2008    96.99   31.59   56.42   58.36   17.31
01/17/2008    96.49   31.48   55.16   57.79   16.80
01/18/2008    98.68   31.38   55.65   56.58   16.62
01/22/2008    96.60   30.38   53.47   54.76   16.06
01/23/2008   101.26   30.35   52.53   54.84   16.47
01/24/2008   102.03   31.61   54.39   55.78   15.96
01/25/2008    99.75   31.31   54.15   54.41   15.57
01/28/2008   100.19   31.10   54.34   55.34   15.90
01/29/2008   101.26   30.99   54.47   54.54   15.92
01/30/2008   100.83   30.61   53.48   53.81   15.96
01/31/2008   102.22   30.99   54.73   54.96   16.18
02/01/2008   104.10   28.95   54.99   55.20   16.39
02/04/2008   103.01   28.70   55.12   54.62   16.69
02/05/2008   100.23   27.63   54.33   53.47   16.07
02/06/2008    99.24   27.11   54.53   53.76   16.34
02/07/2008    98.04   26.73   53.95   54.45   15.95
02/08/2008    98.94   27.15   55.03   55.19   15.95
02/11/2008   100.73   26.82   55.46   55.43   16.05
02/12/2008   102.06   26.94   56.11   55.82   16.22
02/13/2008   103.87   27.53   57.14   55.32   16.17
02/14/2008   101.68   27.09   56.85   54.54   15.94
02/15/2008   101.70   27.02   56.21   54.74   15.87
02/19/2008   100.59   26.88   57.33   54.12   15.95
02/20/2008   103.32   26.93   57.23   54.24   16.05
02/21/2008   102.44   26.82   55.81   54.02   15.72
02/22/2008   103.53   26.42   56.79   54.27   15.99
02/25/2008   105.46   26.57   57.86   54.75   16.15
02/26/2008   109.58   27.08   58.37   55.44   16.16
02/27/2008   111.57   26.97   57.57   55.94   16.02
02/28/2008   110.40   26.65   57.32   55.39   15.74
02/29/2008   109.08   25.96   56.20   54.46   15.40
03/03/2008   109.44   25.76   55.99   54.98   15.53
03/04/2008   110.85   26.33   55.53   55.30   15.54
03/05/2008   110.55   26.84   56.96   55.59   15.47
03/06/2008   107.80   26.31   55.24   55.05   15.15
03/07/2008   109.16   26.60   55.32   54.82   15.05
03/10/2008   109.22   26.77   55.89   54.64   15.03
03/11/2008   111.60   27.94   56.99   55.40   15.62
03/12/2008   112.16   27.32   57.11   55.49   15.39
03/13/2008   111.04   27.31   56.75   55.25   15.58
03/14/2008   110.39   26.68   55.65   53.93   15.36
03/17/2008   110.70   27.01   53.74   54.08   15.75
03/18/2008   113.44   28.08   54.85   55.70   15.92
03/19/2008   112.03   27.31   52.04   56.21   15.58
03/20/2008   113.36   27.85   51.89   57.23   16.01
03/24/2008   114.06   27.84   52.56   57.36   15.81
03/25/2008   113.02   27.81   53.50   57.57   15.63
03/26/2008   112.00   27.26   53.68   57.33   15.75
03/27/2008   110.67   26.77   52.55   57.48   15.63
03/28/2008   109.76   26.64   51.91   57.13   15.55
03/31/2008   110.31   27.08   52.54   57.07   15.67
04/01/2008   111.60   28.15   53.18   57.60   15.92
04/02/2008   109.99   27.83   54.03   56.68   16.06
04/03/2008   111.15   27.68   54.15   56.78   15.97
04/04/2008   110.90   27.83   54.56   56.49   15.91
04/07/2008   111.43   27.83   54.98   56.60   16.04
04/08/2008   111.39   27.44   55.32   56.73   16.16
04/09/2008   111.87   27.57   56.23   56.98   16.13
04/10/2008   113.79   27.78   56.26   57.50   16.11
04/11/2008   111.13   26.99   56.01   56.52   15.96
04/14/2008   112.36   26.78   56.84   57.19   15.84
04/15/2008   112.25   26.96   56.72   57.13   15.84
04/16/2008   115.41   27.63   58.30   57.33   16.20
04/17/2008   117.91   27.89   58.51   56.89   16.08
04/18/2008   119.18   28.63   59.08   56.35   16.14
04/21/2008   119.13   29.03   59.28   56.58   16.04
04/22/2008   118.48   28.87   59.63   56.15   15.87
04/23/2008   118.41   30.01   59.92   56.55   16.14
04/24/2008   118.98   30.35   58.75   56.49   15.99
04/25/2008   117.91   28.47   59.93   55.62   16.21
04/28/2008   116.58   27.67   59.76   55.29   16.05
04/29/2008   117.69   27.33   62.53   55.05   15.98
04/30/2008   115.63   27.22   63.06   55.19   16.07
05/01/2008   118.42   28.06   62.30   55.40   16.39
05/02/2008   118.01   27.90   62.57   55.10   16.67
05/05/2008   116.91   27.75   62.78   54.73   16.44
05/06/2008   117.66   28.34   63.10   54.63   16.47
05/07/2008   119.42   27.88   62.49   53.47   16.21
05/08/2008   120.17   27.93   62.98   52.77   16.28
05/09/2008   119.34   28.05   62.46   52.64   16.21
05/12/2008   120.47   28.62   63.24   52.88   16.42
05/13/2008   121.76   28.52   62.76   52.97   16.32
05/14/2008   122.67   28.67   63.11   53.01   16.58
05/15/2008   123.57   29.17   64.19   53.45   16.45
05/16/2008   122.96   28.73   65.52   53.50   16.47
05/19/2008   121.68   28.22   65.55   53.93   16.64
05/20/2008   120.42   27.55   65.65   53.52   16.51
05/21/2008   118.91   27.06   66.61   53.11   16.47
05/22/2008   119.95   27.27   66.69   54.63   16.55
05/23/2008   119.47   26.87   65.77   54.97   16.17
05/27/2008   122.47   27.24   64.45   54.93   16.25
05/28/2008   124.61   26.99   63.71   53.85   16.34
05/29/2008   124.77   27.12   63.13   54.25   16.36
05/30/2008   124.50   27.13   63.53   53.68   16.41
06/02/2008   122.51   26.63   62.23   53.44   16.09
06/03/2008   122.97   26.16   61.51   52.88   15.96
06/04/2008   122.70   26.38   59.14   53.16   16.12
06/05/2008   123.58   27.11   60.81   53.62   16.14
06/06/2008   120.18   26.33   60.36   52.31   15.71
06/09/2008   121.07   26.54   61.86   52.37   16.08
06/10/2008   121.15   26.71   60.02   54.38   15.91
06/11/2008   118.56   25.98   61.23   53.92   15.93
06/12/2008   119.14   27.05   60.57   53.92   15.85
06/13/2008   121.35   27.84   59.93   52.30   16.12
06/16/2008   121.89   27.71   60.35   51.13   16.17
06/17/2008   120.34   27.59   61.07   50.92   16.17
06/18/2008   119.43   27.26   60.08   50.17   16.08
06/19/2008   120.26   27.71   59.07   50.36   16.09
06/20/2008   118.07   27.04   59.01   50.64   15.69
06/23/2008   118.76   26.79   59.64   50.26   15.76
06/24/2008   118.76   26.56   58.94   50.36   15.60
06/25/2008   119.84   27.15   60.31   51.05   15.76
06/26/2008   116.52   26.58   59.54   50.22   15.30
06/27/2008   115.48   26.46   59.39   48.92   15.16
06/30/2008   114.02   26.35   60.95   49.05   15.44
07/01/2008   114.73   25.74   59.73   48.13   15.34
07/02/2008   114.57   24.79   57.42   48.48   15.33
07/03/2008   114.99   24.88   58.12   48.58   15.20
07/07/2008   116.88   24.93   58.22   48.40   15.26
07/08/2008   119.17   24.76   57.71   48.57   15.53
07/09/2008   115.82   24.17   56.47   48.02   15.55
07/10/2008   118.49   24.38   56.86   47.22   15.50
07/11/2008   117.47   24.19   56.54   47.44   15.45
07/14/2008   116.91   24.09   56.36   48.09   15.28
07/15/2008   118.51   25.05   54.59   48.87   15.33
07/16/2008   121.15   26.11   53.99   49.39   15.17
07/17/2008   121.70   26.36   53.89   47.51   15.26
07/18/2008   124.95   24.77   54.67   47.21   15.44
07/21/2008   123.76   24.56   55.19   46.81   15.42
07/22/2008   125.05   24.71   55.16   48.46   15.42
07/23/2008   124.59   25.32   54.29   49.54   15.29
07/24/2008   125.05   24.37   53.38   48.94   15.38
07/25/2008   123.64   25.06   53.95   49.13   15.27
07/28/2008   121.44   24.42   54.15   48.27   15.19
07/29/2008   122.80   25.01   52.78   48.67   15.34
07/30/2008   123.96   25.12   54.40   48.42   15.56
07/31/2008   123.11   24.64   53.83   48.60   15.61
08/01/2008   121.82   24.37   53.62   50.15   15.25
08/04/2008   122.70   24.21   52.75   50.87   15.43
08/05/2008   123.97   25.10   52.77   51.82   15.69
08/06/2008   124.73   25.88   53.96   52.24   15.49
08/07/2008   124.62   26.24   53.74   50.97   15.47
08/08/2008   124.39   26.94   52.59   52.29   16.15
08/11/2008   122.26   26.72   52.78   52.23   16.47
08/12/2008   120.92   26.93   53.42   51.70   15.85
08/13/2008   121.48   26.73   52.92   52.10   15.98
08/14/2008   122.58   26.73   52.26   51.92   15.81
08/15/2008   122.02   26.64   51.10   51.96   16.00
08/18/2008   120.31   26.52   51.10   51.27   16.10
08/19/2008   118.35   26.27   51.03   51.27   15.92
08/20/2008   118.31   26.24   51.04   51.29   15.93
08/21/2008   118.77   26.14   51.88   50.50   15.89
08/22/2008   120.64   26.77   50.76   51.31   16.04
08/25/2008   118.64   26.60   50.46   50.55   15.83
08/26/2008   118.30   26.22   50.55   50.51   15.93
08/27/2008   119.15   26.50   51.69   50.76   15.95
08/28/2008   120.31   26.87   51.20   50.13   16.05
08/29/2008   117.55   26.24   51.20   49.14   15.69
09/02/2008   114.35   26.06   47.98   49.03   15.60
09/03/2008   114.28   25.87   48.36   48.75   15.40
09/04/2008   111.05   25.34   48.20   48.80   15.56
09/05/2008   110.41   24.67   48.00   49.01   15.58
09/08/2008   113.27   25.12   48.32   50.37   16.08
09/09/2008   111.09   25.10   46.55   50.85   16.29
09/10/2008   113.99   25.43   47.52   50.78   16.08
09/11/2008   115.11   26.29   47.46   51.46   16.39
09/12/2008   114.89   26.56   48.68   51.80   16.47
09/15/2008   111.24   25.79   46.13   52.03   16.07
09/16/2008   112.07   24.99   46.48   52.13   16.23
09/17/2008   107.65   23.63   45.67   50.05   15.64
09/18/2008   111.17   24.29   45.72   50.74   16.73
09/19/2008   114.77   24.20   48.46   50.11   16.17
09/22/2008   112.22   24.43   49.00   48.83   16.17
09/23/2008   111.40   24.46   48.06   48.17   15.90
09/24/2008   112.46   24.73   47.57   47.70   16.06
09/25/2008   115.99   25.59   49.16   48.91   16.17
09/26/2008   115.32   26.35   48.46   49.88   16.22
09/29/2008   110.53   24.05   43.66   48.50   15.85
09/30/2008   112.95   25.67   44.57   50.26   15.68
10/01/2008   106.35   25.46   44.53   51.47   16.03
10/02/2008   101.15   25.24   41.79   50.94   15.78
10/03/2008    99.89   25.31   42.42   49.96   15.62
10/06/2008    97.17   23.95   40.56   48.39   15.40
10/07/2008    92.37   22.34   39.46   46.85   15.27
10/08/2008    87.44   22.13   39.71   45.06   15.23
10/09/2008    85.95   21.44   36.16   41.15   13.63
10/10/2008    84.74   20.68   36.02   39.44   12.98
10/13/2008    89.05   24.52   41.31   44.92   14.71
10/14/2008    90.39   23.18   41.50   41.56   14.14
10/15/2008    85.26   21.79   36.74   42.02   13.33
10/16/2008    88.38   23.26   39.48   43.51   13.97
10/17/2008    87.66   23.01   39.36   42.01   13.63
10/20/2008    89.34   23.77   45.25   44.16   15.01
10/21/2008    85.81   22.46   41.99   43.75   14.13
10/22/2008    80.73   20.70   38.42   43.13   13.90
10/23/2008    81.46   21.46   40.03   40.92   14.76
10/24/2008    79.25   21.12   37.84   39.55   14.06
10/27/2008    76.93   20.37   35.67   38.98   14.14
10/28/2008    84.29   22.21   41.33   43.01   15.01
10/29/2008    85.17   22.12   43.71   41.68   14.61
10/30/2008    87.58   21.76   44.05   42.45   15.14
10/31/2008    89.78   21.47   44.15   41.87   14.74
11/03/2008    89.50   21.75   43.06   43.20   15.00
11/04/2008    90.20   22.63   45.54   43.75   15.22
11/05/2008    86.85   21.23   43.49   42.51   14.05
11/06/2008    82.69   20.08   41.74   42.28   14.09
11/07/2008    83.78   20.68   43.97   43.96   14.62
11/10/2008    81.44   20.48   43.33   43.62   14.32
11/11/2008    80.35   20.39   41.82   42.24   14.25
11/12/2008    77.43   19.52   38.11   41.66   13.97
11/13/2008    81.78   20.44   40.35   43.98   14.71
11/14/2008    78.01   19.29   39.71   42.79   14.28
11/17/2008    75.24   18.58   39.61   41.79   14.05
11/18/2008    77.76   19.00   41.17   41.33   14.32
11/19/2008    73.77   17.71   39.24   40.17   13.61
11/20/2008    69.67   16.97   35.78   39.03   13.36
11/21/2008    72.71   19.05   39.20   41.82   13.73
11/24/2008    77.58   20.03   41.74   42.99   14.11
11/25/2008    78.32   19.35   42.88   42.83   14.00
11/26/2008    79.31   19.84   43.75   43.50   13.82
11/28/2008    79.24   19.58   44.04   44.92   14.21
12/01/2008    74.68   18.02   39.41   42.49   13.46
12/02/2008    77.53   18.54   41.50   42.11   13.24
12/03/2008    78.34   19.24   41.00   44.22   13.48
12/04/2008    75.20   18.50   39.19   42.89   13.32
12/05/2008    78.26   19.24   39.37   44.07   13.64
12/08/2008    82.41   20.34   41.58   44.07   13.64
12/09/2008    80.30   19.94   41.45   42.97   13.25
12/10/2008    80.46   19.95   41.76   43.43   13.44
12/11/2008    78.25   18.83   42.64   42.38   13.29
12/12/2008    79.82   18.74   42.55   42.72   13.35
12/15/2008    80.38   18.43   43.19   43.10   13.25
12/16/2008    83.90   19.47   44.63   44.53   13.64
12/17/2008    83.36   19.03   44.86   43.59   13.34
12/18/2008    81.57   18.69   42.02   43.30   13.49
12/19/2008    81.10   18.51   40.82   42.59   13.40
12/22/2008    79.62   18.57   40.61   42.81   13.55
12/23/2008    78.27   18.67   40.50   42.14   13.18
12/24/2008    78.19   18.56   39.95   42.27   13.34
12/26/2008    78.98   18.52   40.21   42.73   13.29
12/29/2008    78.90   18.36   40.99   42.57   13.38
12/30/2008    81.13   18.72   41.45   43.06   13.64
12/31/2008    81.73   18.82   42.28   43.39   13.71
01/02/2009    84.84   19.68   43.83   43.99   14.06
01/05/2009    84.31   19.87   44.35   43.55   14.40
01/06/2009    86.65   20.10   44.37   42.85   14.01
01/07/2009    85.25   18.89   42.93   43.06   14.04
01/08/2009    84.66   19.48   44.15   43.36   14.07
01/09/2009    82.25   18.90   42.63   42.75   13.94
01/12/2009    83.23   18.85   41.34   41.91   14.03
01/13/2009    82.87   19.19   40.90   42.19   13.84
01/14/2009    80.78   18.48   39.07   40.85   13.69
01/15/2009    81.69   18.63   39.35   41.56   13.57
01/16/2009    82.46   19.08   39.99   42.02   13.71
01/20/2009    79.61   17.89   37.33   41.10   13.59
01/21/2009    88.78   18.76   38.07   41.49   13.56
01/22/2009    87.47   16.57   37.48   41.33   13.57
01/23/2009    86.90   16.65   36.89   40.45   13.60
01/26/2009    88.95   17.07   38.62   41.24   13.84
01/27/2009    89.01   17.10   38.95   41.53   13.97
01/28/2009    92.08   17.47   39.30   42.04   14.06
01/29/2009    89.84   17.03   38.39   41.74   14.07
01/30/2009    89.00   16.56   38.42   40.95   13.83
02/02/2009    88.30   17.26   37.60   40.49   13.71
02/03/2009    90.78   17.91   38.25   41.52   13.74
02/04/2009    90.15   18.04   38.89   40.64   14.02
02/05/2009    89.74   18.43   40.03   40.92   14.13
02/06/2009    93.87   19.03   41.19   41.74   14.32
02/09/2009    94.53   18.82   41.12   40.55   14.30
02/10/2009    91.07   18.20   39.32   38.98   13.89
02/11/2009    92.91   18.60   39.47   39.56   13.85
02/12/2009    92.82   18.65   40.11   42.55   13.79
02/13/2009    91.62   18.48   39.66   42.03   13.67
02/17/2009    88.53   17.63   38.01   40.83   13.08
02/18/2009    89.35   17.66   37.58   40.91   13.36
02/19/2009    86.83   17.46   37.89   41.50   13.44
02/20/2009    86.69   17.55   37.01   41.06   13.13
02/23/2009    82.38   16.78   35.67   40.34   12.90
02/24/2009    84.36   16.74   36.98   41.27   13.27
02/25/2009    83.87   16.53   36.86   40.61   13.14
02/26/2009    86.87   16.01   36.00   39.36   12.78
02/27/2009    89.86   15.74   35.41   39.15   12.49
03/02/2009    86.95   15.39   32.44   38.04   11.98
03/03/2009    85.70   15.48   31.51   37.22   11.33
03/04/2009    87.38   15.71   33.06   38.08   11.51
03/05/2009    85.41   14.89   31.88   36.28   11.16
03/06/2009    83.78   14.90   32.60   37.48   11.26
03/09/2009    81.51   14.77   33.39   37.14   10.95
03/10/2009    85.19   16.06   34.36   37.53   11.49
03/11/2009    86.53   16.68   34.34   38.33   11.63
03/12/2009    88.26   16.58   35.30   39.56   11.73
03/13/2009    88.22   16.23   35.34   39.93   11.92
03/16/2009    89.06   15.84   35.46   39.98   12.20
03/17/2009    90.71   16.47   36.32   40.15   12.53
03/18/2009    89.78   16.53   36.87   40.34   12.97
03/19/2009    90.47   16.71   37.11   40.86   13.14
03/20/2009    90.32   16.63   36.37   41.30   13.18
03/23/2009    96.38   17.87   38.67   42.76   13.62
03/24/2009    95.98   17.48   38.11   42.64   13.16
03/25/2009    95.64   17.43   38.26   43.35   13.20
03/26/2009    96.45   18.36   38.51   43.44   13.41
03/27/2009    91.93   17.67   37.76   43.69   13.25
03/30/2009    92.29   17.04   36.39   42.54   13.08
03/31/2009    94.60   17.91   37.01   42.57   13.28
04/01/2009    95.30   18.82   37.31   43.45   13.22
04/02/2009    98.44   18.80   38.43   43.92   13.15
04/03/2009    99.80   18.28   38.15   43.56   13.16
04/06/2009    99.16   18.29   37.58   43.58   13.03
04/07/2009    96.42   18.29   36.59   43.22   12.76
04/08/2009    98.80   18.71   36.55   43.58   12.97
04/09/2009    99.30   19.17   36.93   43.58   12.94
04/13/2009    97.59   19.10   36.85   43.33   12.90
04/14/2009    96.92   18.86   36.17   42.82   12.72
04/15/2009    96.51   18.36   36.30   43.62   12.98
04/16/2009    99.03   19.26   36.93   43.69   12.86
04/17/2009    98.88   18.72   37.04   43.61   12.74
04/20/2009    98.06   18.14   35.90   42.94   12.72
04/21/2009    99.89   18.49   36.71   41.74   12.82
04/22/2009   100.13   18.31   36.10   41.58   12.72
04/23/2009    99.02   18.44   37.70   41.57   12.81
04/24/2009    97.71   20.38   38.82   41.45   12.75
04/27/2009    97.59   19.89   38.69   40.91   12.78
04/28/2009    99.53   19.43   39.34   40.95   12.84
04/29/2009   101.58   19.74   39.79   41.37   12.97
04/30/2009   100.77   19.75   39.19   41.70   12.80
05/01/2009   102.14   19.73   40.49   41.14   13.08
05/04/2009   103.68   19.68   41.55   41.82   13.19
05/05/2009   103.35   19.29   41.39   41.79   13.16
05/06/2009   102.68   19.29   42.58   41.59   12.97
05/07/2009   100.69   18.83   42.61   41.46   13.16
05/08/2009    99.61   18.93   44.62   41.57   13.15
05/11/2009   100.99   18.83   43.38   41.41   13.29
05/12/2009   102.01   19.39   44.25   43.01   13.35
05/13/2009   100.36   19.25   43.25   42.26   13.02
05/14/2009    99.18   19.55   43.42   43.49   12.94
05/15/2009    99.49   19.71   42.86   43.55   12.71
05/18/2009   102.64   20.08   44.40   44.62   12.77
05/19/2009   103.55   19.92   44.25   45.18   12.78
05/20/2009   102.12   19.99   44.89   45.53   12.65
05/21/2009   100.91   19.44   44.54   45.22   12.68
05/22/2009   100.00   19.37   44.72   45.82   12.90
05/26/2009   103.07   19.95   45.61   45.73   13.22
05/27/2009   101.02   19.75   45.17   45.17   12.96
05/28/2009   102.75   20.06   45.86   45.43   13.22
05/29/2009   104.31   20.49   46.50   47.62   13.34
06/01/2009   106.36   20.99   48.74   47.48   13.54
06/02/2009   104.85   20.99   49.15   48.10   13.29
06/03/2009   104.52   21.32   47.68   47.55   13.27
06/04/2009   104.36   21.42   47.83   48.20   13.26
06/05/2009   105.25   21.72   47.31   47.89   13.32
06/08/2009   105.50   21.63   48.24   47.83   13.28
06/09/2009   106.14   21.66   48.81   47.55   13.27
06/10/2009   106.34   22.12   49.00   46.89   13.33
06/11/2009   107.37   22.40   49.05   47.46   13.61
06/12/2009   106.20   22.89   48.10   47.76   13.83
06/15/2009   105.63   22.97   46.83   47.00   13.62
06/16/2009   105.33   23.00   46.32   46.73   13.41
06/17/2009   105.02   23.23   45.47   46.82   13.47
06/18/2009   104.36   23.05   44.83   48.41   13.80
06/19/2009   103.93   23.61   45.87   47.68   13.58
06/22/2009   102.58   22.84   44.01   46.88   13.81
06/23/2009   102.50   22.90   44.26   46.70   13.56
06/24/2009   102.22   23.02   44.13   46.40   13.57
06/25/2009   104.09   23.34   44.56   46.74   13.79
06/26/2009   103.72   22.91   44.38   47.02   13.58
06/29/2009   103.87   23.41   45.06   47.17   13.74
06/30/2009   102.48   23.32   44.79   46.88   13.75
07/01/2009   102.90   23.58   45.07   48.04   13.98
07/02/2009    99.84   22.93   44.21   47.75   13.57
07/06/2009    99.77   22.76   43.15   47.87   13.77
07/07/2009    98.33   22.10   42.59   47.52   13.50
07/08/2009    98.81   22.13   42.57   47.39   13.47
07/09/2009   100.19   22.01   42.78   47.58   13.41
07/10/2009    98.96   21.96   42.48   47.19   13.50
07/13/2009   101.70   22.79   43.40   47.92   13.73
07/14/2009   101.34   22.67   43.59   48.15   13.69
07/15/2009   105.23   23.66   45.40   49.36   13.91
07/16/2009   108.59   23.98   45.98   49.62   13.92
07/17/2009   113.28   23.83   45.77   49.16   13.88
07/20/2009   114.28   24.06   47.11   49.85   13.91
07/21/2009   114.87   24.36   46.93   49.19   14.03
07/22/2009   113.43   24.33   46.65   48.00   13.99
07/23/2009   114.89   25.07   47.63   48.04   14.28
07/24/2009   115.46   23.00   47.58   48.22   14.51
07/27/2009   115.45   22.67   48.23   48.38   14.56
07/28/2009   115.11   23.02   46.97   48.25   14.42
07/29/2009   115.09   23.35   46.66   48.14   14.47
07/30/2009   115.68   23.36   46.85   48.52   14.64
07/31/2009   115.74   23.07   47.01   48.69   14.59
08/03/2009   117.70   23.38   48.90   48.45   14.68
08/04/2009   117.38   23.32   48.59   48.36   14.68
08/05/2009   116.27   23.36   48.43   48.03   14.45
08/06/2009   115.74   23.01   47.45   48.25   14.56
08/07/2009   117.66   23.11   48.02   48.20   14.77
08/10/2009   117.04   22.97   48.10   48.30   14.63
08/11/2009   116.15   22.69   47.75   47.91   14.70
08/12/2009   117.63   23.08   48.05   47.34   14.63
08/13/2009   117.91   23.17   48.41   47.01   14.65
08/14/2009   116.92   23.24   48.17   47.35   14.72
08/17/2009   115.23   22.81   46.98   47.58   14.62
08/18/2009   115.99   23.26   47.82   47.49   14.60
08/19/2009   116.92   23.33   48.37   48.22   14.68
08/20/2009   117.29   23.35   48.86   48.28   14.83
08/21/2009   118.23   24.08   49.91   48.76   14.94
08/24/2009   117.65   24.31   49.56   47.93   15.03
08/25/2009   117.17   24.31   49.61   47.61   14.95
08/26/2009   117.80   24.22   49.07   48.04   14.97
08/27/2009   117.76   24.36   49.56   48.30   14.95
08/28/2009   116.57   24.35   49.65   47.93   14.94
08/31/2009   116.40   24.32   49.15   47.64   14.83
09/01/2009   115.06   23.68   48.21   47.41   14.64
09/02/2009   114.47   23.54   50.18   48.65   14.50
09/03/2009   114.71   23.78   50.44   48.43   14.66
09/04/2009   115.82   24.29   50.81   48.80   14.86
09/08/2009   115.53   24.49   51.74   49.25   14.86
09/09/2009   115.13   24.45   52.49   49.46   14.77
09/10/2009   116.03   24.66   52.58   49.41   14.77
09/11/2009   116.40   24.52   52.14   50.73   14.77
09/14/2009   117.22   24.66   51.86   51.37   14.98
09/15/2009   117.68   24.86   51.70   51.66   14.99
09/16/2009   120.12   24.86   52.20   51.87   15.17
09/17/2009   120.18   24.96   52.35   52.61   15.14
09/18/2009   120.41   24.92   52.34   52.95   15.28
09/21/2009   119.87   24.96   51.98   52.20   15.08
09/22/2009   119.91   25.42   52.91   52.05   15.04
09/23/2009   119.13   25.36   51.81   51.79   15.05
09/24/2009   119.25   25.59   50.81   51.55   15.13
09/25/2009   119.39   25.21   50.55   52.17   15.15
09/28/2009   117.66   25.48   51.16   52.33   15.26
09/29/2009   117.15   25.40   51.21   52.50   15.18
09/30/2009   117.94   25.37   50.85   52.89   15.07
10/01/2009   116.25   24.54   49.46   52.32   14.94
10/02/2009   117.36   24.62   48.46   53.06   14.72
10/05/2009   118.08   24.31   49.14   52.99   14.85
10/06/2009   119.66   24.77   50.15   53.50   14.95
10/07/2009   121.07   24.76   49.89   53.98   15.01
10/08/2009   120.58   25.32   50.40   53.76   14.92
10/09/2009   124.17   25.21   49.93   53.82   14.93
10/12/2009   125.27   25.37   50.28   53.96   14.97
10/13/2009   125.25   25.46   50.32   53.97   14.94
10/14/2009   126.56   25.61   51.26   54.01   15.11
10/15/2009   126.19   26.35   52.31   54.09   15.17
10/16/2009   119.94   26.14   52.55   54.18   15.11
10/19/2009   121.34   26.00   53.88   53.96   15.30
10/20/2009   121.11   26.01   53.67   53.25   15.27
10/21/2009   119.18   26.22   53.90   53.25   15.46
10/22/2009   120.98   26.23   54.11   53.33   15.50
10/23/2009   118.68   27.64   52.94   52.44   15.41
10/26/2009   118.43   28.29   53.00   52.43   15.26
10/27/2009   118.97   28.20   55.23   52.65   15.22
10/28/2009   119.80   27.64   54.28   52.70   15.16
10/29/2009   121.16   27.84   55.69   53.27   15.42
10/30/2009   118.93   27.36   54.09   52.50   15.14
11/02/2009   118.88   27.50   54.71   52.91   15.11
11/03/2009   119.47   27.16   54.97   52.32   15.05
11/04/2009   119.60   27.68   55.00   52.68   15.12
11/05/2009   121.38   28.09   55.91   53.58   15.36
11/06/2009   122.31   28.14   55.82   53.67   15.36
11/09/2009   124.80   28.60   57.25   54.64   15.61
11/10/2009   125.70   28.62   57.29   54.97   15.72
11/11/2009   125.98   28.73   56.51   55.28   15.68
11/12/2009   125.06   28.96   55.48   55.09   15.55
11/13/2009   125.82   29.23   56.53   55.61   15.58
11/16/2009   126.99   29.14   57.41   55.88   15.74
11/17/2009   127.40   29.73   57.65   56.01   15.73
11/18/2009   126.93   29.84   57.39   55.72   15.70
11/19/2009   126.32   29.51   56.80   56.02   15.64
11/20/2009   125.75   29.35   56.03   56.61   15.76
11/23/2009   126.98   29.67   56.81   57.36   15.99
11/24/2009   126.71   29.64   56.89   57.31   16.09
11/25/2009   126.07   29.52   57.37   57.23   16.27
11/27/2009   124.50   28.95   56.30   56.72   16.22
11/30/2009   125.15   29.14   55.40   56.74   16.21
12/01/2009   126.72   29.74   56.75   57.61   16.62
12/02/2009   126.00   29.51   56.81   57.49   16.76
12/03/2009   126.33   29.56   55.82   56.81   16.78
12/04/2009   126.04   29.71   56.06   57.02   16.65
12/07/2009   125.83   29.52   56.36   57.40   16.89
12/08/2009   125.59   29.30   55.26   57.21   16.95
12/09/2009   127.17   29.44   54.93   57.36   16.95
12/10/2009   128.11   29.60   54.63   58.10   17.17
12/11/2009   128.44   29.58   54.69   58.63   17.30
12/14/2009   128.69   29.84   55.00   58.56   17.20
12/15/2009   127.27   29.75   54.67   58.58   17.15
12/16/2009   127.48   29.83   55.26   57.95   17.05
12/17/2009   126.19   29.33   54.16   56.52   16.84
12/18/2009   126.69   30.08   54.43   56.46   16.90
12/21/2009   127.42   30.24   55.46   56.72   16.88
12/22/2009   128.69   30.54   55.69   56.81   16.77
12/23/2009   128.76   30.64   56.10   56.82   16.75
12/24/2009   129.33   30.72   56.42   56.97   16.78
12/28/2009   131.05   30.89   56.80   56.97   16.85
12/29/2009   130.59   31.10   56.24   57.27   16.90
12/30/2009   131.31   30.68   56.35   57.21   16.92
12/31/2009   129.65   30.20   56.16   56.54   16.72
01/04/2010   131.19   30.67   57.31   56.58   16.49
01/05/2010   129.60   30.68   57.71   55.89   16.22
01/06/2010   128.76   30.49   58.01   55.87   16.27
01/07/2010   128.32   30.17   57.99   55.73   16.35
01/08/2010   129.60   30.38   58.13   54.70   16.36
01/11/2010   128.25   29.99   59.96   55.81   16.53
01/12/2010   129.27   29.80   59.58   56.42   16.55
01/13/2010   128.99   30.07   59.87   56.57   16.58
01/14/2010   131.05   30.68   59.81   56.67   16.58
01/15/2010   130.52   30.58   59.72   55.83   16.42
01/19/2010   132.86   30.82   60.38   55.96   16.60
01/20/2010   129.01   30.31   59.16   55.05   16.45
01/21/2010   127.77   29.74   57.71   53.93   16.21
01/22/2010   124.30   28.70   56.07   53.80   16.08
01/25/2010   124.92   29.05   56.72   53.91   16.19
01/26/2010   124.55   29.23   56.67   53.70   16.33
01/27/2010   125.13   29.40   56.25   54.07   16.26
01/28/2010   122.57   28.89   55.54   53.74   16.15
01/29/2010   121.22   27.92   54.37   53.81   16.06
02/01/2010   123.48   28.15   55.45   53.94   16.18
02/02/2010   124.33   28.20   53.73   54.60   16.28
02/03/2010   124.46   28.37   53.45   54.42   16.17
02/04/2010   121.83   27.59   51.81   53.00   15.90
02/05/2010   122.34   27.76   51.52   52.66   15.86
02/08/2010   121.26   27.47   50.80   52.22   15.86
02/09/2010   122.58   27.75   51.94   53.57   16.09
02/10/2010   122.18   27.73   51.98   53.35   15.99
02/11/2010   123.10   27.86   53.09   53.78   15.98
02/12/2010   123.37   27.68   52.97   53.54   15.92
02/16/2010   124.59   28.22   54.21   54.37   16.02
02/17/2010   125.69   28.46   53.35   54.88   15.95
02/18/2010   127.16   28.84   53.84   55.46   16.10
02/19/2010   126.54   28.64   53.41   55.27   16.37
02/22/2010   126.20   28.60   53.36   54.93   16.20
02/23/2010   125.82   28.20   52.35   54.38   16.12
02/24/2010   126.94   28.50   52.70   54.71   16.22
02/25/2010   126.42   28.47   52.02   52.69   16.15
02/26/2010   126.51   28.54   52.34   52.29   16.12
03/01/2010   127.91   28.89   53.09   52.84   16.26
03/02/2010   126.77   28.33   53.11   52.87   16.21
03/03/2010   126.23   28.33   53.96   53.49   16.17
03/04/2010   126.07   28.50   54.19   54.03   16.10
03/05/2010   126.60   28.46   54.86   54.26   16.23
03/08/2010   125.77   28.50   55.25   54.02   16.30
03/09/2010   124.91   28.67   55.12   53.74   16.24
03/10/2010   124.98   28.84   55.27   53.76   16.24
03/11/2010   126.95   29.05   55.67   53.60   16.25
03/12/2010   127.29   29.14   55.93   53.35   16.10
03/15/2010   127.18   29.16   55.65   53.65   16.23
03/16/2010   128.01   29.24   56.24   53.70   16.37
03/17/2010   127.11   29.50   57.20   53.84   16.38
03/18/2010   127.73   29.48   57.20   53.95   16.35
03/19/2010   127.06   29.46   56.74   54.75   16.35
03/22/2010   127.33   29.47   56.41   54.54   16.21
03/23/2010   128.71   29.75   57.00   55.30   16.23
03/24/2010   127.87   29.52   56.29   54.62   16.09
03/25/2010   128.58   29.88   55.60   54.80   16.07
03/26/2010   128.60   29.53   55.76   54.65   16.19
03/29/2010   127.93   29.46   55.96   54.77   16.35
03/30/2010   128.11   29.64   55.90   54.87   16.17
03/31/2010   127.60   29.16   56.13   55.00   16.09
04/01/2010   127.60   29.03   56.79   55.30   16.18
04/05/2010   128.69   29.14   57.55   54.86   16.19
04/06/2010   128.27   29.19   58.39   54.29   16.32
04/07/2010   127.82   29.22   57.82   53.82   16.14
04/08/2010   126.96   29.79   58.00   53.76   16.01
04/09/2010   128.10   30.20   58.48   54.59   16.10
04/12/2010   127.71   30.18   58.37   54.76   16.03
04/13/2010   128.37   30.31   58.32   55.02   15.99
04/14/2010   130.58   30.68   59.02   54.95   15.98
04/15/2010   130.22   30.73   59.58   54.26   15.90
04/16/2010   129.96   30.53   58.90   54.97   15.78
04/19/2010   131.56   30.90   58.50   55.32   15.84
04/20/2010   129.03   31.22   59.49   54.47   16.12
04/21/2010   128.33   31.19   59.10   54.19   16.07
04/22/2010   128.47   31.25   58.57   54.31   15.98
04/23/2010   129.33   30.82   58.90   53.88   16.02
04/26/2010   130.06   30.97   56.96   53.73   16.01
04/27/2010   128.16   30.71   55.41   52.87   15.78
04/28/2010   129.44   30.77   56.40   53.36   16.40
04/29/2010   129.79   30.86   51.70   53.74   16.30
04/30/2010   128.34   30.40   51.29   53.45   16.54
05/03/2010   128.94   30.72   49.37   53.76   16.69
05/04/2010   127.47   29.99   50.36   53.18   16.47
05/05/2010   126.81   29.72   50.99   53.66   16.52
05/06/2010   123.92   28.85   50.33   52.30   16.25
05/07/2010   122.10   28.08   49.06   52.67   16.32
05/10/2010   126.27   28.81   48.75   54.04   16.66
05/11/2010   126.89   28.75   48.74   53.61   16.68
05/12/2010   132.68   29.31   48.50   54.02   16.74
05/13/2010   131.48   29.11   48.10   53.49   16.62
05/14/2010   131.19   28.80   46.87   53.34   16.54
05/17/2010   130.44   28.81   46.57   53.41   16.69
05/18/2010   129.95   28.60   45.38   53.10   16.70
05/19/2010   128.86   28.24   45.27   53.12   16.49
05/20/2010   123.80   27.11   44.58   51.54   15.97
05/21/2010   125.42   26.84   43.86   51.59   16.00
05/24/2010   124.45   26.27   41.86   51.46   15.97
05/25/2010   124.52   26.07   42.56   50.62   15.82
;

/* Printing first 10 observations of the data */
proc print data = returns(obs=10);
run;

/* Keep only the last 250 observations of the data */
data returns;
   set returns nobs=observ;
   if (_N_ > observ-250);
run;

/* Copula estimation and simulation of returns */
proc copula data = returns;
   var ret_ibm ret_msft ret_bp ret_ko ret_duk;
   * fit T-copula to stock returns;
   fit T /
          marginals = empirical
          method    = MLE
          plots      = (datatype = both);
   * simulate 10000 observations;
   * independent in time, dependent in cross-section;
   simulate /
            ndraws = 10000
            seed   = 1234
            out    = simulated_returns
            plots(unpack) = (datatype = original);
run;

/* compute equally weighted portfolio return */
data port_ret (drop = i ret);
   set simulated_returns;
   array returns{5} ret_ibm ret_msft ret_bp ret_ko ret_duk;
   ret =0;
   do i =1 to 5;
      ret = ret+ 0.2*exp(returns[i]);
   end;
   port_ret = ret-1;
run;

/* compute descriptive statistics */
/* quantile table will give Value-at-Risk estimates for the portfolio */
proc univariate data = port_ret;
   var port_ret;
run;