<?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: Getting yearly average of each firm. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574813#M162482</link>
    <description>SQL doesn't use the formatted value when aggregating, it uses the underlying values.  However if you use PROC MEANS or any other PROC it will use the formatted values.</description>
    <pubDate>Thu, 18 Jul 2019 22:30:23 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-07-18T22:30:23Z</dc:date>
    <item>
      <title>Getting yearly average of each firm.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574809#M162479</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data credit1;
set credit;
format datadate year.;
rename datadate = year;
run;

proc sql;
create table credtY as 
 select cusip, year, mean(rating) as ratingY 
  from credit1
   group by cusip, year;
   quit;&lt;/CODE&gt;&lt;/PRE&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: 454px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31134i3F9B277A74097474/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;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is no error or warning sign on the above coding... So I think the code itself works but I need sth else to get what I want.&lt;/P&gt;&lt;P&gt;I ran the code to get yearly average ratings(ratingY) for each frim of each year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, what I get is the same monthly ratings as the previous data file is.&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;I changed YYMMDD date to Year&lt;/STRONG&gt;&lt;/U&gt; and use the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming the reason why I couldn't obtain the desired outcome is 1) many duplicates or 2) Year is not really a year but YYMMDD...&amp;nbsp;&lt;/P&gt;&lt;P&gt;To resolve this issue, I used "nodupkey" to delete duplicates but failed to delete them at all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to ask how can I can&amp;nbsp;yearly average of each firm when I have seemingly duplicate Years BUT&amp;nbsp;possibly YYMMDD.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 21:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574809#M162479</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-18T21:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Getting yearly average of each firm.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574813#M162482</link>
      <description>SQL doesn't use the formatted value when aggregating, it uses the underlying values.  However if you use PROC MEANS or any other PROC it will use the formatted values.</description>
      <pubDate>Thu, 18 Jul 2019 22:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574813#M162482</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-18T22:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Getting yearly average of each firm.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574814#M162483</link>
      <description>Thank you Reeza!!!&lt;BR /&gt;I rather use proc means so!</description>
      <pubDate>Thu, 18 Jul 2019 22:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574814#M162483</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-18T22:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting yearly average of each firm.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574823#M162490</link>
      <description>&lt;P&gt;Yeah... I passed the first hurdle. But... if my YEARS are based on underlying values, how can I merge later? I need to use YEAR to match... Can I use input() statement to convert my YEAR to a PURE year?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If not... is there any ways to use this YEAR with underlying values for matching with normal pure years?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 23:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574823#M162490</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-18T23:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getting yearly average of each firm.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574830#M162495</link>
      <description>If you're joining in SQL you can actually join with a function. &lt;BR /&gt;&lt;BR /&gt;select * &lt;BR /&gt;from x&lt;BR /&gt;left join y&lt;BR /&gt;on year(x.date) = year(y.date)</description>
      <pubDate>Fri, 19 Jul 2019 00:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574830#M162495</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-19T00:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Getting yearly average of each firm.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574980#M162534</link>
      <description>Thank you Reeza,&lt;BR /&gt;This is good! I will apply this code now and later!</description>
      <pubDate>Fri, 19 Jul 2019 15:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-yearly-average-of-each-firm/m-p/574980#M162534</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-19T15:14:37Z</dc:date>
    </item>
  </channel>
</rss>

