<?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 Re: Calculate lag of 6 Quater percentage change for 300 variables in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901363#M43917</link>
    <description>Period var1 var2 var3 ....... var276&lt;BR /&gt;2010Q1 2.3 9 10 ....... 50&lt;BR /&gt;2010Q2 5.3 24 44 ....... 3&lt;BR /&gt;2010Q3 18.4 16 15 ........ 55&lt;BR /&gt;2010Q4 20 2 3 ........ 4&lt;BR /&gt;2011Q1 2 5 18 ........ 11&lt;BR /&gt;2012Q2 5.6 2 22 ......... 50&lt;BR /&gt;2013Q3 7 10 30 ......... 5&lt;BR /&gt;2014Q4 1 30 50 ........ 18.5&lt;BR /&gt;Upto&lt;BR /&gt;2050Q4</description>
    <pubDate>Fri, 03 Nov 2023 10:54:07 GMT</pubDate>
    <dc:creator>droydroy</dc:creator>
    <dc:date>2023-11-03T10:54:07Z</dc:date>
    <item>
      <title>Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901360#M43915</link>
      <description>We have 300 variables in the data set. Each variable is having quaterly data , for an example starting from Q12010 to Q12020. Now I am trying to calculate for each variable what will be the lag value of 6 quater percentage change. So I need to create 6 quater percentage change of eaxh variable and then calculate their lag values. Please help.</description>
      <pubDate>Fri, 03 Nov 2023 10:36:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901360#M43915</guid>
      <dc:creator>droydroy</dc:creator>
      <dc:date>2023-11-03T10:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901362#M43916</link>
      <description>&lt;P&gt;Its not exactly clear to me how your data is arranged. Is it something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;var1                         var2

data for q12010       data for q12010
data for q22010       data for q22010
data for q32010       data for q32010
...&amp;nbsp; &amp;nbsp;                           ...&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If yes, then we can help you create a program. If no, then we need to know the arrangement of the data before we can be of any help, in this case SHOW US a portion of the data (we don't need all 300 variables, but 2 or 3 would be great).&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 10:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901362#M43916</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T10:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901363#M43917</link>
      <description>Period var1 var2 var3 ....... var276&lt;BR /&gt;2010Q1 2.3 9 10 ....... 50&lt;BR /&gt;2010Q2 5.3 24 44 ....... 3&lt;BR /&gt;2010Q3 18.4 16 15 ........ 55&lt;BR /&gt;2010Q4 20 2 3 ........ 4&lt;BR /&gt;2011Q1 2 5 18 ........ 11&lt;BR /&gt;2012Q2 5.6 2 22 ......... 50&lt;BR /&gt;2013Q3 7 10 30 ......... 5&lt;BR /&gt;2014Q4 1 30 50 ........ 18.5&lt;BR /&gt;Upto&lt;BR /&gt;2050Q4</description>
      <pubDate>Fri, 03 Nov 2023 10:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901363#M43917</guid>
      <dc:creator>droydroy</dc:creator>
      <dc:date>2023-11-03T10:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901364#M43918</link>
      <description>&lt;P&gt;Thanks, now please walk us through one example of performing the calculation of "lag of 6 Quater percentage change", using the above data that you provided.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 11:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901364#M43918</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T11:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901371#M43919</link>
      <description>6qtr percentage change = [( value in 2011Q2 - value in 2010Q1)/ value in 2010Q1]*100&lt;BR /&gt;&lt;BR /&gt;Need to code in such a way that it can be used for 3qtr / 10 Qtr / 12 Qtr etc.</description>
      <pubDate>Fri, 03 Nov 2023 11:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901371#M43919</guid>
      <dc:creator>droydroy</dc:creator>
      <dc:date>2023-11-03T11:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901372#M43920</link>
      <description>&lt;P&gt;First I provide code where the 6 month is hard-coded, and then I modify the code to allow for 10 month or 12 month or whatever.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* UNTESTED CODE */
data want;
    set have;
    array v var1-var276;
    array pctchg pctchg1-pctchg276;
    do i=1 to dim(v);
         pctchg(i)=100*(v(i)-lag5(v(i)))/lag5(v(i)); /* 6 months ago is found via lag5 */
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example code where you can change the lag&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* UNTESTED CODE */
%let lag_desired=10;
%let lag_to_use=%eval(&amp;amp;lag_desired-1);

data want;
    set have;
    array v var1-var276;
    array pctchg pctchg1-pctchg276;
    do i=1 to dim(v);
         pctchg(i)=100*(v(i)-lag&amp;amp;lag_to_use(v(i)))/lag&amp;amp;lag_to_use(v(i)); 
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Nov 2023 11:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901372#M43920</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T11:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901373#M43921</link>
      <description>Thanks a lot</description>
      <pubDate>Fri, 03 Nov 2023 11:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901373#M43921</guid>
      <dc:creator>droydroy</dc:creator>
      <dc:date>2023-11-03T11:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901374#M43922</link>
      <description>Shall I create another loop to calculate lag of of these percentage change values ?&lt;BR /&gt;Can that step be incorporated in this loop ?&lt;BR /&gt;&lt;BR /&gt;Aim is to calculate lag1 or lagi for these percentage change values</description>
      <pubDate>Fri, 03 Nov 2023 11:39:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901374#M43922</guid>
      <dc:creator>droydroy</dc:creator>
      <dc:date>2023-11-03T11:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901375#M43923</link>
      <description>&lt;P&gt;If I am understanding you properly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array v var1-var276;
    array pctchg pctchg1-pctchg276;
    array lagpctchg lagpctchg1-lagpctchg276;
    do i=1 to dim(v);
         pctchg(i)=100*(v(i)-lag5(v(i)))/lag5(v(i)); /* 6 months ago is found via lag5 */
         lagpctchg(i)=lag(pctchg(i));
     end;
     drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Nov 2023 11:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901375#M43923</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T11:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate lag of 6 Quater percentage change for 300 variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901377#M43924</link>
      <description>Now I understood the logic behind arrays. Thanks a lot for teaching.</description>
      <pubDate>Fri, 03 Nov 2023 11:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-lag-of-6-Quater-percentage-change-for-300-variables/m-p/901377#M43924</guid>
      <dc:creator>droydroy</dc:creator>
      <dc:date>2023-11-03T11:52:50Z</dc:date>
    </item>
  </channel>
</rss>

