<?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 adjust the proc means to have mean with the denominator is lag value? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-adjust-the-proc-means-to-have-mean-with-the-denominator/m-p/725080#M225172</link>
    <description>&lt;P&gt;Using results from other values of Class or By variables means that you will need to take the results into a data step and use Lag functions or possibly use Proc SQL with a reflexive join (a table with itself) on something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On t1.loc = t2.loc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and t1.year=(t2.year-1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"shorter" depends on the complexity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not that it reduces the complexity, such as it may be of the code, but you can request the N= statistic so you have some "nicer" than _freq_ if you don't like the variable name.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Mar 2021 09:20:33 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-03-10T09:20:33Z</dc:date>
    <item>
      <title>How to adjust the proc means to have mean with the denominator is lag value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-adjust-the-proc-means-to-have-mean-with-the-denominator/m-p/725048#M225155</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally, we got the mean from proc means by the average of the variables in a group of call variables called from statement "BY".&lt;/P&gt;
&lt;P&gt;I also did the same thing&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=inter noprint;
by LOC year;
var amihud;
output out=agg_amihud_ew  mean=agg_mh_ew_year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So,agg_mh_ew_year will be calculated by the &lt;STRONG&gt;average of all firms's amihud in one country in one year&lt;/STRONG&gt;. However, what I want is to calculate agg_amh_ew_year that&lt;STRONG&gt; total of all firms'amihud this year divide by the number of firms in one country &lt;FONT color="#FF0000"&gt;&lt;EM&gt;last&lt;/EM&gt;&lt;/FONT&gt; year&lt;/STRONG&gt;. I think that it will relate to the variable _FREQ_ but I do not know how to adjust the code. Could you please help me to sort it out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My novice idea is to create a datastep and then create the lag_freq, then I calculated the desired variable based on multiplying to&lt;STRONG&gt;_FREQ_&lt;/STRONG&gt; and then divide to &lt;STRONG&gt;lagfreq&lt;/STRONG&gt;. Is there any other shorter idea though?&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 05:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-adjust-the-proc-means-to-have-mean-with-the-denominator/m-p/725048#M225155</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-10T05:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to adjust the proc means to have mean with the denominator is lag value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-adjust-the-proc-means-to-have-mean-with-the-denominator/m-p/725080#M225172</link>
      <description>&lt;P&gt;Using results from other values of Class or By variables means that you will need to take the results into a data step and use Lag functions or possibly use Proc SQL with a reflexive join (a table with itself) on something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On t1.loc = t2.loc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and t1.year=(t2.year-1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"shorter" depends on the complexity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not that it reduces the complexity, such as it may be of the code, but you can request the N= statistic so you have some "nicer" than _freq_ if you don't like the variable name.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 09:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-adjust-the-proc-means-to-have-mean-with-the-denominator/m-p/725080#M225172</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-10T09:20:33Z</dc:date>
    </item>
  </channel>
</rss>

