How to continuously calculate volitility using data in the

Discussion in 'SAS (Statistical Analysis Software)' started by Hei Hei, Mar 5, 2008.

  1. Hei Hei

    Hei Hei Guest

    1. data file- daily equity return from 1971 to 2007;
    2. Assuming the volatility at time t is estimated by the daily return data
    of the previous 252 days (trading days in a year);
    3. Q: How to write the program to continuously estimate the daily volatility
    from 1971 to 2007 and write these volatility estimates into a separate file?
     
    Hei Hei, Mar 5, 2008
    #1
    1. Advertisements

  2. Hei Hei

    Dirk Nachbar Guest

    well you probably need a macro for this

    data all; run;

    %macro loop;

    %do i=252 %to &nobs;
    proc summary data=in;
    var r;
    where &i-251<time<=&i;
    output out=vol&i std=;
    run;

    data all;
    set all vol&i;
    run;
    %end;

    data all;
    set all;
    vol=r**2;
    run;
    Dirk
     
    Dirk Nachbar, Mar 5, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.