<?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: proc sql, group by in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474653#M121972</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216039"&gt;@zilong567&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But my problem is that the observations go from 36 thousand to more than 1 billion. And there are many same results, with same lpermno, same fyear and same lstkvol. I couldn't find the reason.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I take it that your dataset A has about 36000 observations, but you are wondering why the table resulting from this left join consists of &amp;gt;1 billion observations and that this is mainly due to duplicate observations ("&lt;SPAN&gt;same results, with same lpermno, ...").&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The reason is that "&lt;FONT face="courier new,courier"&gt;The query requires remerging summary statistics back with the original data.&lt;/FONT&gt;" -- as the SAS log must have told you. To avoid the duplicates, you can either insert the keyword &lt;STRONG&gt;distinct&lt;/STRONG&gt; after "select" or – better – extend the &lt;STRONG&gt;group by&lt;/STRONG&gt; clause by all other variables from A (in particular &lt;FONT face="courier new,courier"&gt;a.lfybegdt, a.lfyenddt&lt;/FONT&gt;). The advantage of extending the &lt;STRONG&gt;group by&lt;/STRONG&gt; clause is that remerging does &lt;EM&gt;not&lt;/EM&gt; occur (see SAS log), which reduces run time.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 01 Jul 2018 09:14:29 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-07-01T09:14:29Z</dc:date>
    <item>
      <title>proc sql, group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474648#M121968</link>
      <description>&lt;P&gt;I use the method group by to obtain stock volitality from crsp daily stock file. But my problem is that the observations go from 36 thousand to more than 1 billion. And there are many same results, with same lpermno, same fyear and same lstkvol. I couldn't find the reason. Thanks!&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table exe_ccn_lancmpcrsp as&lt;BR /&gt;select a.*,std(b.RET)*sqrt(250) as lstkvol "lag annualized stock volitality"&lt;BR /&gt;from exe_ccn_lancmpllq a left join crspa.DSF b&lt;BR /&gt;on a.lpermno=b.permno and b.DATE between a.lfybegdt and a.lfyenddt&lt;BR /&gt;group by a.lpermno,a.fyear&lt;BR /&gt;having sum(b.RET is not missing)&amp;gt;1;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jun 2018 08:28:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474648#M121968</guid>
      <dc:creator>zilong567</dc:creator>
      <dc:date>2018-06-30T08:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql, group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474652#M121971</link>
      <description>&lt;P&gt;I don't understand your problem? Please elaborate.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jun 2018 10:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474652#M121971</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-06-30T10:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql, group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474653#M121972</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216039"&gt;@zilong567&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But my problem is that the observations go from 36 thousand to more than 1 billion. And there are many same results, with same lpermno, same fyear and same lstkvol. I couldn't find the reason.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I take it that your dataset A has about 36000 observations, but you are wondering why the table resulting from this left join consists of &amp;gt;1 billion observations and that this is mainly due to duplicate observations ("&lt;SPAN&gt;same results, with same lpermno, ...").&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The reason is that "&lt;FONT face="courier new,courier"&gt;The query requires remerging summary statistics back with the original data.&lt;/FONT&gt;" -- as the SAS log must have told you. To avoid the duplicates, you can either insert the keyword &lt;STRONG&gt;distinct&lt;/STRONG&gt; after "select" or – better – extend the &lt;STRONG&gt;group by&lt;/STRONG&gt; clause by all other variables from A (in particular &lt;FONT face="courier new,courier"&gt;a.lfybegdt, a.lfyenddt&lt;/FONT&gt;). The advantage of extending the &lt;STRONG&gt;group by&lt;/STRONG&gt; clause is that remerging does &lt;EM&gt;not&lt;/EM&gt; occur (see SAS log), which reduces run time.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jul 2018 09:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474653#M121972</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-01T09:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql, group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474697#M121992</link>
      <description>&lt;P&gt;To add to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;'s excellent suggestion...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why a left join with the having condition sum(b.RET is not missing)&amp;gt;1. Table exe_ccn_lancmpllq&amp;nbsp;records without a match in crspa.DSF&amp;nbsp;will have all RET values missing, so they will be dropped by the having condition. You might as well use an inner join.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jun 2018 20:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by/m-p/474697#M121992</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-30T20:55:31Z</dc:date>
    </item>
  </channel>
</rss>

