Resources

SAS Products

SAS Risk Dimensions - Stressing Variables in a Scenario Analysis



Objective

Set Up Your Environment

Define Your Portfolio

Register Market Data

Define Valuation Methods and Instrument Types

Specify the Analysis and Create the Project

Run the Project

Example Code (ZIP file)



Objective

Stress testing enables you to assess how a portfolio performs under adverse market conditions. You can stress test a portfolio using scenario analysis in SAS Risk Dimensions. In such scenarios, you can stress relevant variables:

In this example, you perform stress testing on a portfolio that contains shares in two stocks. You define a scenario in which TechCompany’s stock price drops and you reduce your holding in TechCompany.



Set Up Your Environment

First, set up the library for analysis and the name of the SAS Risk Dimensions environment. Use the directory C:\users\sasdemo\RD_Examples.

libname RDExamp "C:\users\sasdemo\RD_Examples";
%let test_env = stressholding;

In this code, you use the SAS Macro Language facility to create the macro variable Test_Env. You assign the value stressholding to the variable Test_Env.

Using macro variables in this way enables you to change the physical location of the target library and the environment name in just two lines of code. The macro does not directly affect calculations. You can assign the library to any path as long as you have Write access to the referenced directory.

Next, create a new SAS Risk Dimensions environment called stressholding in the RDExamp library.

proc risk;
   env new=RDExamp.&test_env;
   env save;
run;



Define Your Portfolio

Next, describe the assets in your portfolio and register the portfolio data in the environment.

data RDExamp.instdata;
  input insttype $12. instid $8. holding;
  datalines;
TechCompany instid1 1000000
BankCompany instid2 1000000
;

proc risk;
  env open=RDExamp.&test_env;
  instdata Instruments file=RDExamp.instdata format=simple;
  env save;
run;



Register Market Data

Next, provide current risk factor values and the scenario data set. The scenario data set specifies the holding stress and the stressed TechCompany price. Register the current market data and the scenario data in the environment.

data RDExamp.mktdata;
  TEC=15;
  BNK=30;
run;

data RDExamp.scendata;
  length _cvalue_ $ 20;
  input _type_ $ _name_ $ _value_ _ctype_ $ _cvalue_ $;
  datalines;
absolute holding -500000 insttype TechCompany
value    TEC      10     none     none
run;

proc risk;
   env open=RDExamp.&test_env;
   declare riskfactors=(TEC num var, BNK num var);
   marketdata Market file=RDExamp.mktdata  type=current;
   marketdata TechCoScenario file=RDExamp.scendata type=scenarioanalysis;
   env save;
run;



Define Valuation Methods and Instrument Types

Create pricing methods using the COMPILE procedure, and pull them into the environment. Tell the RISK procedure which pricing methods to use for each of the instrument types through assignment in the INSTRUMENT statement. Specify the instrument variables needed for pricing; InstType and InstID do not need to be specified because they are included by default.

proc compile env=RDExamp.&test_env outlib=RDExamp.&test_env;
  method Tech_Price kind=price;
    _value_ = TEC;
  endmethod;
  method Bank_Price kind=price;
    _value_ = BNK;
  endmethod;
run;

proc risk;
  env open=RDExamp.&test_env;
  instrument TechCompany methods=(Price Tech_Price) variables = (holding);
  instrument BankCompany methods=(Price Bank_Price) variables = (holding);
  env save;
run;

When you stress an instrument’s holding, you ask how the value of your portfolio would be different had you bought or sold the instrument. When holding changes are combined with stressed risk factor values, you must capture a two-fold effect. First, you need to capture the effect of the change in the risk factor value; second you must incorporate the holding effect.



Specify the Analysis and Create the Project

Set up a project to compute the Mark-to-Market (MtM) value of your portfolio given the current market. Create a scenario analysis to value the portfolio under the stressed conditions. Build a project to run the analysis.

proc risk;
  env open=RDExamp.&test_env;
  sources InstDataSource (Instruments);
  read sources=InstDataSource out=Portfolio;
  crossclass InstTypeCC (Insttype);

  scenario TechCompanyScen
     data = TechCoScenario
     label = "TechCompany Share Price Decrease";

  project Project
     analysis=(TechCompanyScen)
     portfolio=Portfolio
     crossclass=InstTypeCC
     data=( Market )
     rundate = '07JAN2013'd;
env save;
run;



Run the Project

Run the project, putting output files in the StressHolding_Output subdirectory of the environment directory.

proc risk;
    env open=RDExamp.&test_env;
    runproject Project
    out= StressHolding_Output
    options=(outall);
  env save;
run;


Back to Examples index page