<?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: simple datastep in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158617#M41441</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt; which means the record will be &lt;STRONG&gt;single&lt;/STRONG&gt; with prod_code='b'&amp;nbsp; "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;OP said want only single obs, not sure if your code fit his demand .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data one;
input id prod_type $ prod_code $ ;
cards;
100 a b
101 a b
101 e s
102 n v
102 k l
103 a b
104 a j
105 a b
106 v p
;
run;
 
data want;
 set one;
 by id;
 found=ifc( first.id and last.id and prod_code='b' ,'found',' ');
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 21 Dec 2014 06:30:10 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2014-12-21T06:30:10Z</dc:date>
    <item>
      <title>simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158613#M41437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;I need to find all the records where prod_code='b' and only 'b' which means the record will be single with prod_code='b' and then&amp;nbsp; assign a&amp;nbsp; new var&amp;nbsp; value='found' to that record. &lt;/P&gt;&lt;P&gt;prod code=b is always associated with type=a so i don't need to worry about it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input id prod_type $ prod_code $ ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;100 a b&lt;/P&gt;&lt;P&gt;101 a b&lt;/P&gt;&lt;P&gt;101 e s&lt;/P&gt;&lt;P&gt;102 n v&lt;/P&gt;&lt;P&gt;102 k l&lt;/P&gt;&lt;P&gt;103 a b&lt;/P&gt;&lt;P&gt;104 a j&lt;/P&gt;&lt;P&gt;105 a b&lt;/P&gt;&lt;P&gt;106 v p&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;the output table should be something like :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; id prod_type prod_code value &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;100 a b found&lt;/P&gt;&lt;P&gt;101 a b &lt;/P&gt;&lt;P&gt;101 e s&lt;/P&gt;&lt;P&gt;102 n v&lt;/P&gt;&lt;P&gt;102 k l&lt;/P&gt;&lt;P&gt;103 a b found &lt;/P&gt;&lt;P&gt;104 a j&lt;/P&gt;&lt;P&gt;105 a b found&lt;/P&gt;&lt;P&gt;106 v p&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can do this by creating a new dataset and merging it back to the original but i was wondering if this can be solved in one&amp;nbsp; step (using maybe the order by.... having count(*)=1,........)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts please?&lt;/P&gt;&lt;P&gt;101 has a code=b but&amp;nbsp; also he has a&amp;nbsp; code=s so he does not qualify &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Dec 2014 23:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158613#M41437</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-20T23:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158614#M41438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I correctly understand your requirements, the following might suffice:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *, case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when min(prod_code) eq 'b' and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(prod_code) eq 'b' and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(prod_code eq 'b') eq 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then 'found'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else ''&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end as value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by id&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Dec 2014 23:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158614#M41438</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-12-20T23:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158615#M41439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way to go:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input id prod_type $ prod_code $ ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;100 a b&lt;/P&gt;&lt;P&gt;100 a b&lt;/P&gt;&lt;P&gt;101 a b&lt;/P&gt;&lt;P&gt;101 e s&lt;/P&gt;&lt;P&gt;102 n v&lt;/P&gt;&lt;P&gt;102 k l&lt;/P&gt;&lt;P&gt;103 a b&lt;/P&gt;&lt;P&gt;104 a j&lt;/P&gt;&lt;P&gt;105 a b&lt;/P&gt;&lt;P&gt;106 v p&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select *, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; case &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when count(distinct prod_code)=1 and prod_code='b' then 'found' &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else '' &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end as value &lt;/P&gt;&lt;P&gt;&amp;nbsp; from one&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by id&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Dec 2014 23:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158615#M41439</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-12-20T23:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158616#M41440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;they both work &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you guys &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Dec 2014 01:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158616#M41440</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-21T01:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158617#M41441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt; which means the record will be &lt;STRONG&gt;single&lt;/STRONG&gt; with prod_code='b'&amp;nbsp; "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;OP said want only single obs, not sure if your code fit his demand .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data one;
input id prod_type $ prod_code $ ;
cards;
100 a b
101 a b
101 e s
102 n v
102 k l
103 a b
104 a j
105 a b
106 v p
;
run;
 
data want;
 set one;
 by id;
 found=ifc( first.id and last.id and prod_code='b' ,'found',' ');
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Dec 2014 06:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158617#M41441</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-12-21T06:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158618#M41442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey Xia ,&lt;/P&gt;&lt;P&gt;i forgot to mention that first i'd delete duplicates by id, prod_type,&amp;nbsp; prod_code so Patrick code works too.&lt;BR /&gt;Thanks&amp;nbsp; for your code too. Pretty simple &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Dec 2014 20:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158618#M41442</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-21T20:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158619#M41443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this is the code&amp;nbsp;&amp;nbsp; i initially used :&lt;/P&gt;&lt;P&gt;proc sort data=one;by id prod_type proc_code nodupkey;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; set one;&lt;/P&gt;&lt;P&gt; by id;&lt;/P&gt;&lt;P&gt;if first.id=last.id and prod_code='b' then value='found';&lt;/P&gt;&lt;P&gt;and it did not give me the right output but the it looks right,no?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Dec 2014 20:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158619#M41443</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-21T20:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158620#M41444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not the way you have it written. In your proc sort nodupkey is misplaced and you've misspelled prod_code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plus, your code (once corrected) will assign 'found' when there are actually multiple instances of prod_code eq 'b'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Dec 2014 22:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158620#M41444</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-12-21T22:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158621#M41445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I had it as prod_code and nodupkey was where it was supposed to be in my code but I guess the first and last.I'd logic wasn't right as you are saying.&lt;/P&gt;&lt;P&gt;But I thought first.I'd=last.I'd was true when I have a single record by id&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Dec 2014 22:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158621#M41445</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-21T22:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158622#M41446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The question is: when you have multiple instances of prod_type = 'b' should that, or shouldn't that, be marked as found. The approach you used eliminated the ability to check for such multiple instances since they were deleted during the sort process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Dec 2014 22:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158622#M41446</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-12-21T22:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158623#M41447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can have 101 a b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 101 a b&lt;/P&gt;&lt;P&gt; Then with the sort proc comes down to one and if then &lt;/P&gt;&lt;P&gt;101 has nothing else but a b goes to group found&lt;/P&gt;&lt;P&gt;But if let's say I also had 101 m n then it is a different story( does not qualify). So 101 a b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 101 a b is OK&lt;/P&gt;&lt;P&gt;But 102 a b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 102 a b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 102 n m is not. The client must have only a value of b to be in the group found. I hope I make sense. So all of the codes provided here worked but mine did not&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Dec 2014 23:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158623#M41447</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-21T23:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158624#M41448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since duplicate values of 'b' are ok, then you could simplify my code to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *, case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when min(prod_code) eq 'b' and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(prod_code) eq 'b'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then 'found'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else ''&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end as value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by id&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similarly, your sort and data step would work as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=one nodupkey;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id prod_type prod_code;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set one;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.id and last.id and prod_code='b' then value='found';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 00:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158624#M41448</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-12-22T00:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158625#M41449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So first.I'd=last.I'd was not right in my code?&lt;/P&gt;&lt;P&gt;But if its only one rec by id&amp;nbsp; then first and last are always=1 which means they are equal as I had it in my code. Any way thanks for your lessons and the codes sir&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 00:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158625#M41449</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-22T00:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158626#M41450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code will fail with data like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input id prod_type $ prod_code $ ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;105 a a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;105 a b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;105 a c&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code will show the second record to be 'found' because first.id=0 and last.id=0 (thus first.id=last.id) and prod_code equals 'b'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, your code's logic doesn't match your requirements.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 01:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158626#M41450</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-12-22T01:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: simple datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158627#M41451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;right&amp;nbsp; right i see it now.Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 01:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simple-datastep/m-p/158627#M41451</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-22T01:53:38Z</dc:date>
    </item>
  </channel>
</rss>

