<?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: calculating yearly average! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572597#M161599</link>
    <description>&lt;P&gt;Replace&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;caldt&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;yymmn6&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&amp;nbsp;as&amp;nbsp;yymm&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;by&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year(caldt) as year&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Jul 2019 03:34:44 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2019-07-11T03:34:44Z</dc:date>
    <item>
      <title>calculating yearly average!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572594#M161596</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table snp1 as
  select put(caldt,yymmn6.) as yymm, mean(SPINDX) as mean_price
  from snp
  group by calculated yymm
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think I am almost there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data set is monthly so... instead of having yymm6 I may need something to sum by year. I put some weird things like yyyyn6 and yes. it didn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you tell me how can I get yearly average's' when using monthly data? I have months from 1964 to 2018 so.. there will be more than 50 yearly average!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 210px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30937i5B47B7B7AD148D57/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 03:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572594#M161596</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-11T03:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: calculating yearly average!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572597#M161599</link>
      <description>&lt;P&gt;Replace&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;caldt&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;yymmn6&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&amp;nbsp;as&amp;nbsp;yymm&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;by&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year(caldt) as year&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 03:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572597#M161599</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-07-11T03:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: calculating yearly average!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572618#M161611</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=snp nway;
  class caldt;
  format caldt year.;
  var spindx;
  output out=snp1(drop=_:) mean=mean_price;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could give proc summary a try.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 07:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572618#M161611</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-11T07:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: calculating yearly average!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572688#M161643</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270067"&gt;@JKCho&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table snp1 as
  select put(caldt,yymmn6.) as yymm, mean(SPINDX) as mean_price
  from snp
  group by calculated yymm
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think I am almost there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My data set is monthly so... instead of having yymm6 I may need something to sum by year. I put some weird things like yyyyn6 and yes. it didn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you tell me how can I get yearly average's' when using monthly data? I have months from 1964 to 2018 so.. there will be more than 50 yearly average!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 210px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30937i5B47B7B7AD148D57/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270067"&gt;@JKCho&lt;/a&gt;&amp;nbsp;— as we discussed in one of your other threads, your variable CALDT is already a SAS date value, and is formatted so it appears as 19840107; and so because it is a SAS date value, there is no need (and it is actually wrong) to use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;put(caldt,yymmn6.)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As discussed in your other thread, and as apparent from the other answers in this thread, you simply need to use the YEAR function as shown by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;,&amp;nbsp;and not the PUT function (or alternatively as shown by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;you can use the YEAR. format).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 12:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-yearly-average/m-p/572688#M161643</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-11T12:50:48Z</dc:date>
    </item>
  </channel>
</rss>

