<?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 Counting unique number of all past occurences by groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/572804#M161664</link>
    <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've searched forum and was trying to solve it on my own for few days now. I tried proc sql and data step and nothing works.&lt;BR /&gt;&lt;BR /&gt;My data consists of:&lt;/P&gt;&lt;P&gt;firm_ID&lt;/P&gt;&lt;P&gt;event_date for each firm in my sample&lt;/P&gt;&lt;P&gt;Alliance_ID: alliance that this firm is part of&lt;/P&gt;&lt;P&gt;Partner_ID: partners in the alliance&lt;/P&gt;&lt;P&gt;Alliance_Date_Announced and DateAllianceEnd: are the start and end dates of the alliances.&lt;BR /&gt;&lt;BR /&gt;I need to compute for each firm_ID and each partner_ID, number of all unique alliances that a firm had prior to each event date. In other words, prior alliance history (tenure) for each firm but prior to event_date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also need to compute for each firm_ID, number of past alliances prior to event_date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I am facing that I am double counting ongoing alliances at the time of the event. I am interested in the history of alliances: the ones that firm was part of in the past and currently are not active any more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see screenshot below (also excel file is &lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;attached)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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-center" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30980i73159BCBBC7B7BAB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My SAS code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data try8 ; set stat6;
	by Focal_Firm_ID Partner_ID  Alliance_ID    ;
	if not missing(Alliance_ID) then do;
		if first.Partner_ID then do ;
				seq+1;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help is much appreciated!&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2019 15:52:10 GMT</pubDate>
    <dc:creator>JJ19</dc:creator>
    <dc:date>2019-07-11T15:52:10Z</dc:date>
    <item>
      <title>Counting unique number of all past occurences by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/572804#M161664</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've searched forum and was trying to solve it on my own for few days now. I tried proc sql and data step and nothing works.&lt;BR /&gt;&lt;BR /&gt;My data consists of:&lt;/P&gt;&lt;P&gt;firm_ID&lt;/P&gt;&lt;P&gt;event_date for each firm in my sample&lt;/P&gt;&lt;P&gt;Alliance_ID: alliance that this firm is part of&lt;/P&gt;&lt;P&gt;Partner_ID: partners in the alliance&lt;/P&gt;&lt;P&gt;Alliance_Date_Announced and DateAllianceEnd: are the start and end dates of the alliances.&lt;BR /&gt;&lt;BR /&gt;I need to compute for each firm_ID and each partner_ID, number of all unique alliances that a firm had prior to each event date. In other words, prior alliance history (tenure) for each firm but prior to event_date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also need to compute for each firm_ID, number of past alliances prior to event_date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I am facing that I am double counting ongoing alliances at the time of the event. I am interested in the history of alliances: the ones that firm was part of in the past and currently are not active any more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see screenshot below (also excel file is &lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;attached)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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-center" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30980i73159BCBBC7B7BAB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My SAS code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data try8 ; set stat6;
	by Focal_Firm_ID Partner_ID  Alliance_ID    ;
	if not missing(Alliance_ID) then do;
		if first.Partner_ID then do ;
				seq+1;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help is much appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 15:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/572804#M161664</guid>
      <dc:creator>JJ19</dc:creator>
      <dc:date>2019-07-11T15:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Counting unique number of all past occurences by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/572960#M161717</link>
      <description>This looks like a graph problem to me. If you have licence  for OR or Optimization you could try one the PROCs like OPTGRAPH, OPTNETWORK or OPTNET (not particularly familiar with those, this is more of a gut feeling suggestion).</description>
      <pubDate>Thu, 11 Jul 2019 22:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/572960#M161717</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2019-07-11T22:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Counting unique number of all past occurences by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/572996#M161734</link>
      <description>&lt;P&gt;I can think of a sleek way to try tackling your question.&lt;/P&gt;
&lt;P&gt;But since I will not download an Excel file or type in data, I won't try.&lt;/P&gt;
&lt;P&gt;You really should put more effort in your post.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 05:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/572996#M161734</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-12T05:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Counting unique number of all past occurences by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/573519#M161928</link>
      <description>&lt;P&gt;Hello LinusH, you gave me some useful hints. Really appreciate your help! Never heard about OPTNET so I will check it out.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 14:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-unique-number-of-all-past-occurences-by-groups/m-p/573519#M161928</guid>
      <dc:creator>JJ19</dc:creator>
      <dc:date>2019-07-15T14:42:15Z</dc:date>
    </item>
  </channel>
</rss>

