<?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 the observation in a group in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544173#M74221</link>
    <description>Please help me on this</description>
    <pubDate>Tue, 19 Mar 2019 08:21:45 GMT</pubDate>
    <dc:creator>Divya8</dc:creator>
    <dc:date>2019-03-19T08:21:45Z</dc:date>
    <item>
      <title>Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544060#M74215</link>
      <description>I need to select 7400 and 7470 transaction in each group. Write record to the output when group A has 7400 and 7470 transaction. For group C first record have 7400 transaction but it doesn’t have 7470 transaction in susequent record. So I don’t need to consider that. For group C in need to consider only last 2 rows.&lt;BR /&gt;&lt;BR /&gt;Input&lt;BR /&gt;Group sequence transaction&lt;BR /&gt;A. 100. 1200&lt;BR /&gt;A. 101 7400&lt;BR /&gt;A. 102 1000&lt;BR /&gt;A. 103 7470&lt;BR /&gt;B. 201. 7400&lt;BR /&gt;B. 202. 4044&lt;BR /&gt;B. 203. 4600&lt;BR /&gt;B. 204. 7470&lt;BR /&gt;B. 205. 7400&lt;BR /&gt;B. 206. 7470&lt;BR /&gt;C. 301. 7400&lt;BR /&gt;C. 302. 1000&lt;BR /&gt;C. 303. 7400&lt;BR /&gt;C. 304. 7470&lt;BR /&gt;&lt;BR /&gt;Output should look like&lt;BR /&gt;Group sequence transaction&lt;BR /&gt;A. 101. 7400&lt;BR /&gt;A. 103. 7470&lt;BR /&gt;B. 201. 7400&lt;BR /&gt;B. 204. 7470&lt;BR /&gt;B. 205. 7400&lt;BR /&gt;B. 206. 7470&lt;BR /&gt;C. 303. 7400&lt;BR /&gt;C. 304. 7470</description>
      <pubDate>Mon, 18 Mar 2019 18:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544060#M74215</guid>
      <dc:creator>Divya8</dc:creator>
      <dc:date>2019-03-18T18:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544061#M74216</link>
      <description />
      <pubDate>Mon, 18 Mar 2019 18:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544061#M74216</guid>
      <dc:creator>Divya8</dc:creator>
      <dc:date>2019-03-18T18:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544066#M74217</link>
      <description>&lt;P&gt;Little cheeky answer. Please test and let me know &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;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Group $ sequence transaction;
cards;
A. 100. 1200
A. 101 7400
A. 102 1000
A. 103 7470
B. 201. 7400
B. 202. 4044
B. 203. 4600
B. 204. 7470
B. 205. 7400
B. 206. 7470
C. 301. 7400
C. 302. 1000
C. 303. 7400
C. 304. 7470
;

data w;
set have;
by Group transaction notsorted;
where transaction  in (7400,7470);
if last.transaction;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 18:28:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544066#M74217</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-18T18:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544072#M74218</link>
      <description>&lt;P&gt;Or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Group $ sequence transaction;
cards;
A. 100. 1200
A. 101 7400
A. 102 1000
A. 103 7470
B. 201. 7400
B. 202. 4044
B. 203. 4600
B. 204. 7470
B. 205. 7400
B. 206. 7470
C. 301. 7400
C. 302. 1000
C. 303. 7400
C. 304. 7470
;

data want;
set have;
by Group transaction notsorted;
where transaction  in (7400,7470);
if (last.transaction and transaction=7400) or (first.transaction and transaction=7470);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2019 18:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544072#M74218</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-18T18:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544169#M74220</link>
      <description>I tried both options. It’s working partially. It gives&lt;BR /&gt;&lt;BR /&gt;A. 101. 7400&lt;BR /&gt;A. 103. 7470&lt;BR /&gt;B. 201. 7400&lt;BR /&gt;B. 204. 7470&lt;BR /&gt;B. 205. 7400&lt;BR /&gt;B. 206. 7470&lt;BR /&gt;C 301 7400 - this entry should not come.&lt;BR /&gt;C. 303. 7400&lt;BR /&gt;C. 304. 7470&lt;BR /&gt;&lt;BR /&gt;The above entry not having 7470 transaction. So it’s should not consider</description>
      <pubDate>Tue, 19 Mar 2019 08:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544169#M74220</guid>
      <dc:creator>Divya8</dc:creator>
      <dc:date>2019-03-19T08:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544173#M74221</link>
      <description>Please help me on this</description>
      <pubDate>Tue, 19 Mar 2019 08:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544173#M74221</guid>
      <dc:creator>Divya8</dc:creator>
      <dc:date>2019-03-19T08:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544204#M74222</link>
      <description>&lt;P&gt;It looks like you need to account for a few possibilities:&amp;nbsp; multiple 7400 records, a 7400 without a matching 7470 record, a 7470 record without a matching 7400 record.&amp;nbsp; That will require two passes through the data.&amp;nbsp; Here is one approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   recnum=0;
   _7400_=0;
   _7470_=0;
   do until (last.group or transaction=7470);
      set have;
      by group;
      recnum + 1;
      if transaction=7400 then _7400_ = recnum;
      if transaction=7470 then _7470_ = recnum;
   end;
   recnum=0;
   do until (last.group or transaction=7470);
      set have;
      by group;
      recnum + 1;
      if (0 &amp;lt; _7400_ &amp;lt; _7470_) and
      (recnum = _7400_ or recnum=_7470_) then output;
   end;
   drop recnum _7400_ _7470_;
run;
   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's untested code, so might need a tweak or two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top DO loop locates observations containing 7400 or 7470.&amp;nbsp; The bottom DO loop reads the exact same observations, and outputs, depending on the results of the top DO loop.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 11:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544204#M74222</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-19T11:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544210#M74223</link>
      <description>&lt;P&gt;So you want match 7400 and 7470 one to one strictly ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Group $ sequence transaction;
cards;
A. 100. 1200
A. 101 7400
A. 102 1000
A. 103 7470
B. 201. 7400
B. 202. 4044
B. 203. 4600
B. 204. 7470
B. 205. 7400
B. 206. 7470
C. 301. 7400
C. 302. 1000
C. 303. 7400
C. 304. 7470
;
data have;
 set have;
 by group;
 if first.group or transaction=7400 then n+1;
data _7400 _7470;
 set have;
 if transaction=7400 then output _7400;
 if transaction=7470 then output _7470;
run;
data temp;
 ina=0;inb=0;
 merge _7400(in=ina) _7470(in=inb 
 rename=(sequence=se transaction=tr));
 by group n;
 if ina and inb;
run;
data want;
 set temp;
 output;
 sequence=se; transaction=tr;output;
 drop se tr n;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 11:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544210#M74223</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-03-19T11:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544233#M74224</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266943"&gt;@Divya8&lt;/a&gt;&amp;nbsp; It's nice to note that you have more comprehensive solutions from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;than my lazy one. Nevertheless, to your comment that i marked in &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;red.&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;I ran a test yet again with your sample to see what i get&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A. 101. 7400&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A. 103. 7470&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;B. 201. 7400&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;B. 204. 7470&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;B. 205. 7400&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;B. 206. 7470&lt;/SPAN&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;C 301 7400 - this entry should not come.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN&gt;C. 303. 7400&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C. 304. 7470&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TEST:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Creatinbg sample HAVE*/
data have;
input Group $ sequence transaction;
cards;
A. 100. 1200
A. 101 7400
A. 102 1000
A. 103 7470
B. 201. 7400
B. 202. 4044
B. 203. 4600
B. 204. 7470
B. 205. 7400
B. 206. 7470
C. 301. 7400
C. 302. 1000
C. 303. 7400
C. 304. 7470
;
data want;
set have;
by Group transaction notsorted;
where transaction  in (7400,7470);
if (last.transaction and transaction=7400) or (first.transaction and transaction=7470);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;RESULTS:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" style="height: 171px;" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TH class="l header" style="height: 19px; width: 42px;" scope="col"&gt;Group&lt;/TH&gt;
&lt;TH class="r header" style="height: 19px; width: 64.6667px;" scope="col"&gt;sequence&lt;/TH&gt;
&lt;TH class="r header" style="height: 19px; width: 76px;" scope="col"&gt;transaction&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 42px;"&gt;A.&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 64.6667px;"&gt;101&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 76px;"&gt;7400&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 42px;"&gt;A.&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 64.6667px;"&gt;103&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 76px;"&gt;7470&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 42px;"&gt;B.&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 64.6667px;"&gt;201&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 76px;"&gt;7400&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 42px;"&gt;B.&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 64.6667px;"&gt;204&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 76px;"&gt;7470&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 42px;"&gt;B.&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 64.6667px;"&gt;205&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 76px;"&gt;7400&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 42px;"&gt;B.&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 64.6667px;"&gt;206&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 76px;"&gt;7470&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 42px;"&gt;&lt;STRONG&gt;C.&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 64.6667px;"&gt;&lt;STRONG&gt;303&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 76px;"&gt;7400&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 42px;"&gt;&lt;STRONG&gt;C.&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 64.6667px;"&gt;&lt;STRONG&gt;304&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 76px;"&gt;7470&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How did you get&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;C 301 7400?&lt;/STRONG&gt;&lt;FONT color="#000000"&gt; Can you please check the above results?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 13:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544233#M74224</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-19T13:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544536#M74254</link>
      <description>&lt;P&gt;A small change to the elegant solution suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data want;
set have;
by Group transaction notsorted;
where transaction  in (7400,7470);
if (last.transaction and transaction=7400 and not last.group) or (first.transaction and transaction=7470 and not first.group);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This way, you will not get an output if the first transaction in a group is 7470, or the last transaction in a group is 7400.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 12:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544536#M74254</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-03-20T12:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544817#M74263</link>
      <description>Thank you. It’s working. I tried yours and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; suggestions both are working as exepected</description>
      <pubDate>Thu, 21 Mar 2019 11:44:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/544817#M74263</guid>
      <dc:creator>Divya8</dc:creator>
      <dc:date>2019-03-21T11:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571341#M75294</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; recently I come across the below scenario where the sas logic not giving me the expected output.&lt;BR /&gt;&lt;BR /&gt;I have added another 4320 transaction along with 7470 transaction to check. Below is the code I used&lt;BR /&gt;&lt;BR /&gt;if (last.transaction and transaction=7400 and not last.group) or (first.transaction and transaction=7470 or transaction = ‘4320’ and not first.group);&lt;BR /&gt;run&lt;BR /&gt;D 500 4060&lt;BR /&gt;D 401 7400&lt;BR /&gt;D 403 4320&lt;BR /&gt;D 404 7400&lt;BR /&gt;D 405 7415&lt;BR /&gt;D 406 7420&lt;BR /&gt;D 407 7400&lt;BR /&gt;D 408 7470&lt;BR /&gt;&lt;BR /&gt;Along with earlier mentioned cases i need to get below data for D group&lt;BR /&gt;&lt;BR /&gt;D 401 7400&lt;BR /&gt;D 408 7470&lt;BR /&gt;&lt;BR /&gt;In actual getting&lt;BR /&gt;&lt;BR /&gt;D 401 7400&lt;BR /&gt;D 403 4320&lt;BR /&gt;D 407 7400&lt;BR /&gt;D 408 7470&lt;BR /&gt;&lt;BR /&gt;Please help me on this</description>
      <pubDate>Fri, 05 Jul 2019 09:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571341#M75294</guid>
      <dc:creator>Divya8</dc:creator>
      <dc:date>2019-07-05T09:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571362#M75295</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266943"&gt;@Divya8&lt;/a&gt;&amp;nbsp; &amp;nbsp;I believe Soren's answer works well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also&amp;nbsp; how does transaction 4320 matter when you have already filtered to subset only 7400,7470. Do you mean there's a change in requirement to what is stated as the original objective?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2019 12:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571362#M75295</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-05T12:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571386#M75296</link>
      <description>Yes. There is a change. I need to consider first occurrence of 7400 in a group and the last occurrence of 7470/4320. I have altered the code as below&lt;BR /&gt;&lt;BR /&gt;Data want;&lt;BR /&gt;set have;&lt;BR /&gt;by Group transaction notsorted;&lt;BR /&gt;where transaction in (7400,7470,4320);&lt;BR /&gt;&lt;BR /&gt;if (last.transaction and transaction=7400 and not last.group) or (first.transaction and transaction=7470 or transaction = 4320 and not first.group);&lt;BR /&gt;&lt;BR /&gt;The code is working in for case A,B,C, E but not D&lt;BR /&gt;&lt;BR /&gt;Input&lt;BR /&gt;Group sequence transaction&lt;BR /&gt;A 100 1200 jan10&lt;BR /&gt;A 101 7400 jan10&lt;BR /&gt;A. 102 1000 jan10&lt;BR /&gt;A 103 7470 jan10&lt;BR /&gt;B 201 7400 jan10&lt;BR /&gt;B 202 4044 jan10&lt;BR /&gt;B. 203. 4600 jan10&lt;BR /&gt;B. 204. 7470 jan10&lt;BR /&gt;B. 205. 7400 jan10&lt;BR /&gt;B. 206. 7470 jan10&lt;BR /&gt;C. 301. 7400 jan10&lt;BR /&gt;C. 302. 1000 jan10&lt;BR /&gt;C. 303. 7400 jan10&lt;BR /&gt;C. 304. 7470 jan10&lt;BR /&gt;D 500 4060 jan10&lt;BR /&gt;D 401 7400 jan10&lt;BR /&gt;D 403 4320 jan10&lt;BR /&gt;D 404 7400 jan10&lt;BR /&gt;D 405 7415 jan10&lt;BR /&gt;D 406 7420 jan10&lt;BR /&gt;D 407 7400 jan10&lt;BR /&gt;D 408 7470 jan10&lt;BR /&gt;E 500 7400 jan10&lt;BR /&gt;E 501 1000 jan10&lt;BR /&gt;E 502 4320 jan10&lt;BR /&gt;E 503 7400 jan11&lt;BR /&gt;E 504 7470 jan11&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Output should look like&lt;BR /&gt;Group sequence transaction&lt;BR /&gt;A. 101. 7400 jan10&lt;BR /&gt;A. 103. 7470 jan10&lt;BR /&gt;B. 201. 7400 jan10&lt;BR /&gt;B. 204. 7470 jan10&lt;BR /&gt;B. 205. 7400 jan10&lt;BR /&gt;B. 206. 7470 jan10&lt;BR /&gt;C. 303. 7400 jan10&lt;BR /&gt;C. 304. 7470 jan10&lt;BR /&gt;D 401 7400 jan10&lt;BR /&gt;D 408 7470 jan10&lt;BR /&gt;E 500 7400 jan10&lt;BR /&gt;E 502 4320 jan10&lt;BR /&gt;E 503 7400 jan11&lt;BR /&gt;E 504 7470 jan11&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Jul 2019 13:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571386#M75296</guid>
      <dc:creator>Divya8</dc:creator>
      <dc:date>2019-07-05T13:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571562#M75304</link>
      <description>Please help on this</description>
      <pubDate>Sat, 06 Jul 2019 11:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571562#M75304</guid>
      <dc:creator>Divya8</dc:creator>
      <dc:date>2019-07-06T11:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Find the observation in a group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571564#M75305</link>
      <description>&lt;P&gt;Since you want first one ,Why not pick up 301?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;C. &lt;STRONG&gt;301&lt;/STRONG&gt;. 7400 jan10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C. 302. 1000 jan10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C. 303. 7400 jan10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C. &lt;STRONG&gt;304&lt;/STRONG&gt;. 7470 jan10&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2019 11:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-the-observation-in-a-group/m-p/571564#M75305</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-06T11:39:45Z</dc:date>
    </item>
  </channel>
</rss>

