<?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: find pairs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776145#M246784</link>
    <description>&lt;P&gt;Looks like you're missing a BY after GROUP &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether your progrem does what it is suppose to from there, I can't tell&lt;/P&gt;</description>
    <pubDate>Mon, 25 Oct 2021 08:52:25 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-10-25T08:52:25Z</dc:date>
    <item>
      <title>find pairs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776144#M246783</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I want to find distinct pairs of Cusip (this is the ID) by data and investor. that is find a pair of 2 firms with all their institutional investors by date.&lt;/P&gt;&lt;P&gt;this is the code I use:&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table esg.Holdings2 as&lt;BR /&gt;select distinct a.NCUSIP as A_cusip, a.Ins_own as A_Ins_own, b.NCUSIP as B_cusip, b.Ins_own as B_Ins_own,&lt;BR /&gt;FROM 'esg.Holdings1a' AS A, from 'esg.Holdings1a' AS B&lt;BR /&gt;where a.NCUSIP &amp;lt; b.NCUSIP group rdate, mgrno ;&lt;BR /&gt;quit;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the mistake:&lt;/P&gt;&lt;P&gt;20! B_Ins_own,&lt;BR /&gt;321 FROM 'esg.Holdings1a' AS A, from 'esg.Holdings1a' AS B&lt;BR /&gt;322 where a.NCUSIP &amp;lt; b.NCUSIP group rdate, mgrno ;&lt;BR /&gt;-----&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT,&lt;BR /&gt;FROM, INFORMAT, INTO, LABEL, LEN, LENGTH, TRANSCODE.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attached an example of current data and what I try to do&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 08:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776144#M246783</guid>
      <dc:creator>HEB1</dc:creator>
      <dc:date>2021-10-25T08:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: find pairs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776145#M246784</link>
      <description>&lt;P&gt;Looks like you're missing a BY after GROUP &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether your progrem does what it is suppose to from there, I can't tell&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 08:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776145#M246784</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-10-25T08:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: find pairs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776147#M246786</link>
      <description>hi&lt;BR /&gt;group by is not the problem. the problem is the "where" but I have no&lt;BR /&gt;idea why&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Oct 2021 08:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776147#M246786</guid>
      <dc:creator>HEB1</dc:creator>
      <dc:date>2021-10-25T08:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: find pairs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776174#M246803</link>
      <description>&lt;P&gt;There are several syntax errors in your SQL:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The FROM keyword should come only once in a query, not twice separated by commas&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;There should not be a comma after the last column before FROM.&lt;/LI&gt;
&lt;LI&gt;The GROUP keyword should also be used only once, and it should be followed by a BY&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;My guess is that what you want to do is to match the records by RDATE and MGRNO, which can be accomplished with a JOIN rather than using GROUP BY:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table esg.Holdings2 as
  select distinct 
    a.NCUSIP as A_cusip, 
    a.Ins_own as A_Ins_own, 
    b.NCUSIP as B_cusip, 
    b.Ins_own as B_Ins_own
  from
    'esg.Holdings1a' AS A join 'esg.Holdings1a' AS B
    on a.rdate=b.rdate and a mgrno=b.mgrno and a.NCUSIP &amp;lt; b.NCUSIP;
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Oct 2021 11:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/776174#M246803</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-10-25T11:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: find pairs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/777069#M247178</link>
      <description>Thank you SO MUCH!!!!!</description>
      <pubDate>Thu, 28 Oct 2021 17:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-pairs/m-p/777069#M247178</guid>
      <dc:creator>HEB1</dc:creator>
      <dc:date>2021-10-28T17:21:17Z</dc:date>
    </item>
  </channel>
</rss>

