<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Two Time Series -- Measure of 'In-Sync' or 'In-Phase' in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Two-Time-Series-Measure-of-In-Sync-or-In-Phase/m-p/751373#M4142</link>
    <description>&lt;P&gt;Suppose we have two time-series, X1 and X2.&amp;nbsp; I'm wondering if SAS has a way of showing if the two series are in-sync, or in-phase, vs. out of sync/phase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say we want to execute some action when the sync of X1, X2 is maximally moving in the same direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have to be able to track the sync/phase.&amp;nbsp; Have a measure thereof.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Seems what I am seeking is like a 'moving correlation' -- which takes into account the previous so many days of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any thoughts greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jun 2021 23:28:05 GMT</pubDate>
    <dc:creator>NKormanik</dc:creator>
    <dc:date>2021-06-30T23:28:05Z</dc:date>
    <item>
      <title>Two Time Series -- Measure of 'In-Sync' or 'In-Phase'</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Two-Time-Series-Measure-of-In-Sync-or-In-Phase/m-p/751373#M4142</link>
      <description>&lt;P&gt;Suppose we have two time-series, X1 and X2.&amp;nbsp; I'm wondering if SAS has a way of showing if the two series are in-sync, or in-phase, vs. out of sync/phase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say we want to execute some action when the sync of X1, X2 is maximally moving in the same direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have to be able to track the sync/phase.&amp;nbsp; Have a measure thereof.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Seems what I am seeking is like a 'moving correlation' -- which takes into account the previous so many days of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any thoughts greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 23:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Two-Time-Series-Measure-of-In-Sync-or-In-Phase/m-p/751373#M4142</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2021-06-30T23:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Two Time Series -- Measure of 'In-Sync' or 'In-Phase'</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Two-Time-Series-Measure-of-In-Sync-or-In-Phase/m-p/751590#M4143</link>
      <description>&lt;P&gt;Nicholas,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check this useful post:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Moving-Correlation-For-multiple-variables/td-p/559190" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Moving-Correlation-For-multiple-variables/td-p/559190&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;K&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 22:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Two-Time-Series-Measure-of-In-Sync-or-In-Phase/m-p/751590#M4143</guid>
      <dc:creator>KatScott</dc:creator>
      <dc:date>2021-07-01T22:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Two Time Series -- Measure of 'In-Sync' or 'In-Phase'</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Two-Time-Series-Measure-of-In-Sync-or-In-Phase/m-p/751616#M4144</link>
      <description>&lt;P&gt;I've always been disappointed that PROC EXPAND only does univariate series transformations.&amp;nbsp; That's why in the useful paper mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/388036"&gt;@KatScott&lt;/a&gt;&amp;nbsp;you have to prepare the dataset (e.g. create product X1_2=x1*x2) prior to PROC EXPAND, which of course is followed by a PROC CORR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be a better idea to skip the proc expand, as in:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data need (drop=_:) view=need ;
  set have;
  if _n_=1 then do;
    declare hash h (dataset:'have(obs=0)',ordered:'a');
      h.definekey('date');
      h.definedata(all:'Y');
      h.definedone();
    declare hiter hi ('h');
  end;

  h.add();
  
  _date&amp;amp;winsize=lag&amp;amp;winsize(date);
  window_close_date=date ;
  format window_close_date date9. ;

  if _date&amp;amp;winsize^=. then h.remove(key:_date&amp;amp;winsize);

  if _n_&amp;gt;=&amp;amp;winsize then do _rc=hi.first() by 0 until (hi.next()^=0);
    output;
  end;
run;


proc corr data=need noprint  out=correlations;
  by window_close_date ;
  var x y;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Dataset view NEED simply creates a set of records for each window.&amp;nbsp; In the above instance the window size is 21, and is identified by the variable WINDOW_CLOSE_DATE.&amp;nbsp; Each WINDOW_SIZE_DATE will have 21 records ( and therefore most records will appear in 21 windows) in NEED.&amp;nbsp; &amp;nbsp;For a large windows size, that's a lot of records, but disk activity is kept to a minimum by generating NEED as a data set VIEW, not a data set FILE.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 03:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Two-Time-Series-Measure-of-In-Sync-or-In-Phase/m-p/751616#M4144</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-07-02T03:37:48Z</dc:date>
    </item>
  </channel>
</rss>

