<?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: How to calculate seasonally adjusted asset growth rate for quarterly data??? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-seasonally-adjusted-asset-growth-rate-for/m-p/312838#M67882</link>
    <description>&lt;P&gt;You have in effect&amp;nbsp;three variables (asset_growthrate_std, company_id date_quarterly, with four records per company_id/year, sorted by company_id/date_quarterly.&amp;nbsp;&amp;nbsp;The question is what sample do you want to use for determining seasonality?&amp;nbsp; (1) Do you want to use your entire date range?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm going to assume that (1) you're going to use your entire sample of companies over all your sample date range (I'll assume 1981 through 2010, i.e. 30 year ==&amp;gt; 120 quarters).&amp;nbsp; And I'll assume that you'll be interested in the seasonality indexes averaged over all the years - i.e. each year is weighted equally.&amp;nbsp; And since the item of interest is a rate, I'll assume all companies are equally weighted for each yearly result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program does that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The two dimension array QSUMS has a row for each year from 1981 to 2010, and a column for each quarter.&amp;nbsp; It gets the total asset_growthrate over all companies for the given year/quarter.&lt;/LI&gt;
&lt;LI&gt;The program assumes that for each year, a company's quarterly data are complete.&amp;nbsp; I.e. a company may have data just for some years, but for those years in which it is present, it has data for all 4 quarters.&lt;/LI&gt;
&lt;LI&gt;Note this program makes no assumptions about year-to-year trends.&lt;/LI&gt;
&lt;LI&gt;The DIM(qsums,1) says to get the size of the first dimension of the qsums array, i.e. the number of rows in the array.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want (keep=seasonal_index1-seasonal_index4);
  set have end=end_of_have;

  array qsums{1981:2010,1:4} _temporary_ (120*0);

  qsums{year(date_quarterly),qtr(date_quarterly)}+asset_growthrate;

  /* Get average over years of quartely shares*/
  array seasonal_index {4} seasonal_index1-seasonal_index4 (4*0);
  if end_of_have then do;
    do year=1981 to 2010;
      yearly_total=sum(qsums{year,1},qsums{year,2},qsums{year,3},qsums{year,4});
      do q=1 to 4;
        seasonal_index{q}=seasonal_index{q} + qsums{year,q}/(yearly_total/4);
      end;
    end;
    do q=1 to 4;
      seasonal_index{q}=seasonal_index{q}/dim(qsums,1);
    end;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And (editted later) here's how to use the index to get adjusted rates (i.e. what the yearly rate would be based on a seasonally-adjusted modification of the observed quarterly rate:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data adjusted_rates (drop=seasonal_index1-seasonal_index4);

  if _n_=1 then set want;
  array seasonal_index {4} seasonal_index1-seasonal_index4;

  set have;
  adjusted_rate=asset_growthrate/seasonal_index{qtr(date_quarterly)};
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MK&lt;/P&gt;</description>
    <pubDate>Sun, 20 Nov 2016 01:17:25 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2016-11-20T01:17:25Z</dc:date>
    <item>
      <title>How to calculate seasonally adjusted asset growth rate for quarterly data???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-seasonally-adjusted-asset-growth-rate-for/m-p/264581#M51924</link>
      <description>&lt;P&gt;I need to create a variable to caputure firm-level seasonally adjusted asset growth rate &lt;SPAN&gt;volatility&amp;nbsp;&lt;/SPAN&gt;. I use the following to code to capture the volatility ( I didn't adjust seasonal factor). Can someone let me know if this code is ok or there is some better code to do it?? Also, could someone let me know how to seasonally adjusted the volatility?? I have no clue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=HAVE;&lt;BR /&gt;by company_ID&amp;nbsp;date_quarterly;&lt;BR /&gt;run;&lt;BR /&gt;proc expand data=HAVE&amp;nbsp;out=WANT&amp;nbsp;method=none;&lt;BR /&gt;convert asset_growthrate=asset_growthrate_std / transformout=(movstd 8);&lt;BR /&gt;by company_ID;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2016 14:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-seasonally-adjusted-asset-growth-rate-for/m-p/264581#M51924</guid>
      <dc:creator>OceanDream</dc:creator>
      <dc:date>2016-04-18T14:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate seasonally adjusted asset growth rate for quarterly data???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-seasonally-adjusted-asset-growth-rate-for/m-p/312838#M67882</link>
      <description>&lt;P&gt;You have in effect&amp;nbsp;three variables (asset_growthrate_std, company_id date_quarterly, with four records per company_id/year, sorted by company_id/date_quarterly.&amp;nbsp;&amp;nbsp;The question is what sample do you want to use for determining seasonality?&amp;nbsp; (1) Do you want to use your entire date range?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm going to assume that (1) you're going to use your entire sample of companies over all your sample date range (I'll assume 1981 through 2010, i.e. 30 year ==&amp;gt; 120 quarters).&amp;nbsp; And I'll assume that you'll be interested in the seasonality indexes averaged over all the years - i.e. each year is weighted equally.&amp;nbsp; And since the item of interest is a rate, I'll assume all companies are equally weighted for each yearly result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program does that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The two dimension array QSUMS has a row for each year from 1981 to 2010, and a column for each quarter.&amp;nbsp; It gets the total asset_growthrate over all companies for the given year/quarter.&lt;/LI&gt;
&lt;LI&gt;The program assumes that for each year, a company's quarterly data are complete.&amp;nbsp; I.e. a company may have data just for some years, but for those years in which it is present, it has data for all 4 quarters.&lt;/LI&gt;
&lt;LI&gt;Note this program makes no assumptions about year-to-year trends.&lt;/LI&gt;
&lt;LI&gt;The DIM(qsums,1) says to get the size of the first dimension of the qsums array, i.e. the number of rows in the array.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want (keep=seasonal_index1-seasonal_index4);
  set have end=end_of_have;

  array qsums{1981:2010,1:4} _temporary_ (120*0);

  qsums{year(date_quarterly),qtr(date_quarterly)}+asset_growthrate;

  /* Get average over years of quartely shares*/
  array seasonal_index {4} seasonal_index1-seasonal_index4 (4*0);
  if end_of_have then do;
    do year=1981 to 2010;
      yearly_total=sum(qsums{year,1},qsums{year,2},qsums{year,3},qsums{year,4});
      do q=1 to 4;
        seasonal_index{q}=seasonal_index{q} + qsums{year,q}/(yearly_total/4);
      end;
    end;
    do q=1 to 4;
      seasonal_index{q}=seasonal_index{q}/dim(qsums,1);
    end;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And (editted later) here's how to use the index to get adjusted rates (i.e. what the yearly rate would be based on a seasonally-adjusted modification of the observed quarterly rate:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data adjusted_rates (drop=seasonal_index1-seasonal_index4);

  if _n_=1 then set want;
  array seasonal_index {4} seasonal_index1-seasonal_index4;

  set have;
  adjusted_rate=asset_growthrate/seasonal_index{qtr(date_quarterly)};
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MK&lt;/P&gt;</description>
      <pubDate>Sun, 20 Nov 2016 01:17:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-seasonally-adjusted-asset-growth-rate-for/m-p/312838#M67882</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-20T01:17:25Z</dc:date>
    </item>
  </channel>
</rss>

