<?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: can we get below output with first. and last. or groupformat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150661#M29705</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, it is working partially, but not able handle if "description" are more than two types, below is example&lt;/P&gt;&lt;P&gt;Input :&lt;/P&gt;&lt;P&gt;76536 005666666 Dep Basic AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Dep optnl AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Emp Basic AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Emp Optnl AD&amp;amp;D 20050101&lt;/P&gt;&lt;P&gt;In this case, Output file should contain all these records&lt;/P&gt;&lt;P&gt;76536 005666666 Dep Basic AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Dep optnl AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Emp Basic AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Emp Optnl AD&amp;amp;D 20050101&lt;/P&gt;&lt;P&gt;Please do the needful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 Oct 2014 05:55:42 GMT</pubDate>
    <dc:creator>veeru</dc:creator>
    <dc:date>2014-10-31T05:55:42Z</dc:date>
    <item>
      <title>can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150655#M29699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Input&amp;nbsp; file:&lt;BR /&gt;comp&amp;nbsp;&amp;nbsp; polNo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; description&amp;nbsp;&amp;nbsp; pol-date&lt;BR /&gt;76536 002745782 Emp Basic AD&amp;amp;D 20100101 &lt;BR /&gt;76536 002745782 Emp Basic AD&amp;amp;D 20091001 &lt;BR /&gt;76536 002745782 Emp Basic AD&amp;amp;D 20081001 &lt;BR /&gt;76536 003624352 Emp Basic AD&amp;amp;D 20050101 &lt;BR /&gt;76536&amp;nbsp; 003624352 Emp Optnl AD&amp;amp;D 20050101 &lt;BR /&gt;76536&amp;nbsp; 003728839 Emp Basic AD&amp;amp;D 20060701 &lt;BR /&gt;76536&amp;nbsp; 004600598 Emp Basic AD&amp;amp;D 20091001&lt;/P&gt;&lt;P&gt;Output&lt;BR /&gt;comp&amp;nbsp;&amp;nbsp; polNo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; description&amp;nbsp;&amp;nbsp; pol-date&lt;BR /&gt;76536 002745782 Emp Basic AD&amp;amp;D 20100101&amp;nbsp; &lt;BR /&gt;76536 003624352 Emp Basic AD&amp;amp;D 20050101 &lt;BR /&gt;76536&amp;nbsp; 003624352 Emp Optnl AD&amp;amp;D 20050101 &lt;BR /&gt;76536&amp;nbsp; 003728839 Emp Basic AD&amp;amp;D 20060701 &lt;BR /&gt;76536&amp;nbsp; 004600598 Emp Basic AD&amp;amp;D 20091001&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Outfile should be generated with Latest policy date , If compcode, polNo and pol-date are same but the Description is different then I need to that to be in output file (row 2 and 3). Please let me know sas code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 19:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150655#M29699</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-10-30T19:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150656#M29700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is this data a SAS data set? Since pol-date isn't a normal SAS variable name I thought it might be worth asking.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 19:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150656#M29700</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-10-30T19:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150657#M29701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, Its a SAS Dataset and Variable name is Pol_Date, Thank you inadvance for your support.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 19:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150657#M29701</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-10-30T19:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150658#M29702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select comp,polNo,description,max(pol_date) as pol_date&lt;/P&gt;&lt;P&gt;from have&lt;/P&gt;&lt;P&gt;group by comp,polNo,description;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 19:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150658#M29702</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-10-30T19:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150659#M29703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry @stat@sas, It is not giving expected results, results are like input file only.&lt;/P&gt;&lt;P&gt;Note: Apart comp,polno,description and Pol_date fields, there some other fields in that file, I have not listed out them in example, they are coming as blank when I try to print them thru PUT statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 20:42:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150659#M29703</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-10-30T20:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150660#M29704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sort data=have;&lt;/P&gt;&lt;P&gt;by comp polNo description pol_date;&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;set have;&lt;/P&gt;&lt;P&gt;by comp polno description;&lt;/P&gt;&lt;P&gt;if last.description;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 21:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150660#M29704</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-10-30T21:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150661#M29705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, it is working partially, but not able handle if "description" are more than two types, below is example&lt;/P&gt;&lt;P&gt;Input :&lt;/P&gt;&lt;P&gt;76536 005666666 Dep Basic AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Dep optnl AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Emp Basic AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Emp Optnl AD&amp;amp;D 20050101&lt;/P&gt;&lt;P&gt;In this case, Output file should contain all these records&lt;/P&gt;&lt;P&gt;76536 005666666 Dep Basic AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Dep optnl AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Emp Basic AD&amp;amp;D 20050101 &lt;/P&gt;&lt;P&gt;76536 005666666 Emp Optnl AD&amp;amp;D 20050101&lt;/P&gt;&lt;P&gt;Please do the needful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Oct 2014 05:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150661#M29705</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-10-31T05:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150662#M29706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'd have to provide more sample data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I can see, it should still work and 1 record for each description, the one with the latest date should be outputted. &lt;/P&gt;&lt;P&gt;Or you need to explain your requirements more. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try playing around with the first. last. and your BY group variables to see if a different combination gives you what you want. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Oct 2014 11:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150662#M29706</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-10-31T11:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150663#M29707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is exactly what Reeza's code will yield. Test it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards dlm=',';&lt;/P&gt;&lt;P&gt;length&lt;/P&gt;&lt;P&gt;&amp;nbsp; comp $5&lt;/P&gt;&lt;P&gt;&amp;nbsp; polno $9&lt;/P&gt;&lt;P&gt;&amp;nbsp; description $20&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;informat pol_date yymmdd8.;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;&amp;nbsp; comp polno description pol_date&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;76536,005666666,Dep Basic AD&amp;amp;D,20050101&lt;/P&gt;&lt;P&gt;76536,005666666,Dep optnl AD&amp;amp;D,20050101&lt;/P&gt;&lt;P&gt;76536,005666666,Emp Basic AD&amp;amp;D,20050101&lt;/P&gt;&lt;P&gt;76536,005666666,Emp Optnl AD&amp;amp;D,20050101&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 sort data=have;&lt;/P&gt;&lt;P&gt;by comp polNo description pol_date;&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;set have;&lt;/P&gt;&lt;P&gt;by comp polno description;&lt;/P&gt;&lt;P&gt;if last.description;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;76536&amp;nbsp;&amp;nbsp;&amp;nbsp; 005666666&amp;nbsp;&amp;nbsp;&amp;nbsp; Dep Basic AD&amp;amp;D&amp;nbsp;&amp;nbsp;&amp;nbsp; 20050101&lt;/P&gt;&lt;P&gt;76536&amp;nbsp;&amp;nbsp;&amp;nbsp; 005666666&amp;nbsp;&amp;nbsp;&amp;nbsp; Dep optnl AD&amp;amp;D&amp;nbsp;&amp;nbsp;&amp;nbsp; 20050101&lt;/P&gt;&lt;P&gt;76536&amp;nbsp;&amp;nbsp;&amp;nbsp; 005666666&amp;nbsp;&amp;nbsp;&amp;nbsp; Emp Basic AD&amp;amp;D&amp;nbsp;&amp;nbsp;&amp;nbsp; 20050101&lt;/P&gt;&lt;P&gt;76536&amp;nbsp;&amp;nbsp;&amp;nbsp; 005666666&amp;nbsp;&amp;nbsp;&amp;nbsp; Emp Optnl AD&amp;amp;D&amp;nbsp;&amp;nbsp;&amp;nbsp; 20050101&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Oct 2014 11:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150663#M29707</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-10-31T11:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150664#M29708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Input&amp;nbsp; file:&lt;BR /&gt;comp&amp;nbsp;&amp;nbsp; polNo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; description&amp;nbsp;&amp;nbsp; pol-date&lt;BR /&gt;76536 002745782 Emp Basic AD&amp;amp;D 20100101 &lt;BR /&gt;76536 002745782 Emp Basic AD&amp;amp;D 20091001 &lt;BR /&gt;76536 002745782 Emp Basic AD&amp;amp;D 20081001 &lt;BR /&gt;76536 003624352 Emp Basic AD&amp;amp;D 20050101 &lt;BR /&gt;76536&amp;nbsp; 003624352 Emp Optnl AD&amp;amp;D 20050101 &lt;BR /&gt;76536&amp;nbsp; 003728839 Emp Basic AD&amp;amp;D 20060701 &lt;BR /&gt;76536&amp;nbsp; 004600598 Emp Basic AD&amp;amp;D 20091001&lt;BR /&gt;76536 005666666 Dep Basic AD&amp;amp;D 20050101 &lt;BR /&gt;76536 005666666 Dep optnl AD&amp;amp;D 20050101 &lt;BR /&gt;76536 005666666 Emp Basic AD&amp;amp;D 20050101 &lt;BR /&gt;76536 005666666 Emp Optnl AD&amp;amp;D 20050101&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Output&lt;BR /&gt;comp&amp;nbsp;&amp;nbsp; polNo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; description&amp;nbsp;&amp;nbsp; pol-date&lt;BR /&gt;76536 002745782 Emp Basic AD&amp;amp;D 20100101&amp;nbsp; &lt;BR /&gt;76536 003624352 Emp Basic AD&amp;amp;D 20050101 &lt;BR /&gt;76536&amp;nbsp; 003624352 Emp Optnl AD&amp;amp;D 20050101 &lt;BR /&gt;76536&amp;nbsp; 003728839 Emp Basic AD&amp;amp;D 20060701 &lt;BR /&gt;76536&amp;nbsp; 004600598 Emp Basic AD&amp;amp;D 20091001&lt;BR /&gt;76536 005666666 Dep Basic AD&amp;amp;D 20050101 &lt;BR /&gt;76536 005666666 Dep optnl AD&amp;amp;D 20050101 &lt;BR /&gt;76536 005666666 Emp Basic AD&amp;amp;D 20050101 &lt;BR /&gt;76536 005666666 Emp Optnl AD&amp;amp;D 20050101&lt;/P&gt;&lt;P&gt;Tried with different options, not able to get expected output, Pls do the needful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 06:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150664#M29708</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-11-24T06:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150665#M29709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the code didn't work, show a detailed example of your input, code and the output YOU get. &lt;/P&gt;&lt;P&gt;From everything we can see it should work, so there's something we're not seeing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 09:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150665#M29709</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-24T09:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150666#M29710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My Requirement is : output should have latest policy details&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;fields are:&lt;/SPAN&gt; compcode, pol no, pol description and pol date, some to other fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Following Code I have written&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;input file gets created in previous steps&lt;/P&gt;&lt;P&gt;PROC SORT DATA=inputfile OUT=WORK.TEMP;&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; &lt;/P&gt;&lt;P&gt; BY MCE_COMPANY_CODE MCE_POLICY_NUMBER MCE_PLAN_CODE_DESC&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MCE_POLICY_DATE;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; RUN;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;DATA WORK.outputfile;&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; &lt;/P&gt;&lt;P&gt; SET WORK.TEMP;&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; &lt;/P&gt;&lt;P&gt; BY MCE_COMPANY_CODE MCE_POLICY_NUMBER MCE_PLAN_CODE_DESC;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF LAST.MCE_PLAN_CODE_DESC;&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; &lt;/P&gt;&lt;P&gt;RUN;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issues with below record:&lt;/P&gt;&lt;P&gt;input file data&lt;BR /&gt;346703982|Dep Optional AD&amp;amp;D|N/A|20100101| &lt;BR /&gt;346703982|Emp Basic AD&amp;amp;D|N/A|20050201|INA &lt;BR /&gt;346703982|Emp Optional AD&amp;amp;D|N/A|20050301| &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;output file data (it is suppose print DEP optional record along with below records, but it is not printing it. Like wise it is ignoring some records).&lt;BR /&gt;346703982|Emp Basic AD&amp;amp;D|N/A|20050201|IN &lt;BR /&gt;346703982|Emp Optional AD&amp;amp;D|N/A|20050301 &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 11:23:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150666#M29710</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-11-24T11:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150667#M29711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The "LAST." is behaving different for the same kind of data. Need experts advice on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examples 1:&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;code is working fine for below data &lt;BR /&gt;064421449|Emp Basic AD&amp;amp;D|N/A|20050101|INA &lt;BR /&gt;064421449|Emp Optional AD&amp;amp;D|N/A|20130201| &lt;BR /&gt;064421449|Dep Optional AD&amp;amp;D|N/A|20130201| &lt;BR /&gt;output file:&lt;BR /&gt;064421449|Emp Basic AD&amp;amp;D|N/A|20050101|INA &lt;BR /&gt;064421449|Emp Optional AD&amp;amp;D|N/A|20130201| &lt;BR /&gt;064421449|Dep Optional AD&amp;amp;D|N/A|20130201| &lt;/P&gt;&lt;P&gt;-----&lt;/P&gt;&lt;P&gt;Another example&lt;/P&gt;&lt;P&gt;Input data,this policy data same like above, &lt;BR /&gt;346703982|Emp Basic AD&amp;amp;D|N/A|20050201|INA &lt;BR /&gt;346703982|Emp Optional AD&amp;amp;D|N/A|20050301| &lt;BR /&gt;346703982|Dep Optional AD&amp;amp;D|N/A|20100101| &lt;/P&gt;&lt;P&gt;Outfile data:&lt;BR /&gt;it is writing only two records, It should write "Dep Optional" record as well.&lt;BR /&gt;346703982|Emp Basic AD&amp;amp;D|N/A|20050201|IN &lt;BR /&gt;346703982|Emp Optional AD&amp;amp;D|N/A|20050301 &lt;/P&gt;&lt;P&gt;&amp;nbsp; -----&lt;/P&gt;&lt;P&gt;Below is the code for reference.&lt;/P&gt;&lt;P&gt;PROC SORT DATA=inputfile OUT=WORK.TEMP;&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; &lt;/P&gt;&lt;P&gt; BY MCE_COMPANY_CODE MCE_POLICY_NUMBER MCE_PLAN_CODE_DESC&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MCE_POLICY_DATE;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; RUN;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;DATA WORK.outputfile;&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; &lt;/P&gt;&lt;P&gt; SET WORK.TEMP;&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; &lt;/P&gt;&lt;P&gt; BY MCE_COMPANY_CODE MCE_POLICY_NUMBER MCE_PLAN_CODE_DESC;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF LAST.MCE_PLAN_CODE_DESC;&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; &lt;/P&gt;&lt;P&gt;RUN;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Quick help is highly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 14:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150667#M29711</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-11-24T14:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150668#M29712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am afraid you will need to clarify your post.&amp;nbsp; Post the code, actual code, with some test data (in a datastep) where this is happening.&amp;nbsp; For instance you mention it is writing only two lines, writing what, where?&amp;nbsp; no indication of how this is being written.&amp;nbsp; The following code works fine (flags all three recods), so there must be something else happening.&amp;nbsp; Run through your code step by step, replacing the if last then output with a flag so you can see in each step what is happening.&amp;nbsp; Identify exactly the datastep that is causing you problems.&amp;nbsp; Then look at the data for those rows.&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines dlm="|" dsd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input MCE_COMPANY_CODE MCE_POLICY_NUMBER $ MCE_PLAN_CODE_DESC $ A B $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;346703982|Emp Basic AD&amp;amp;D|N/A|20050201|INA &lt;/P&gt;&lt;P&gt;346703982|Emp Optional AD&amp;amp;D|N/A|20050301| &lt;/P&gt;&lt;P&gt;346703982|Dep Optional AD&amp;amp;D|N/A|20100101| &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=have;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; by mce_company_code mce_policy_number mce_plan_code_desc;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by mce_company_code mce_policy_number mce_plan_code_desc;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.mce_plan_code_desc then flag="Y";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 14:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150668#M29712</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-11-24T14:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150669#M29713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the confusion. there are million records in input file. for the same kind of data, it is (Last.)returning different results.(like above). Using the below statement to print the output file.&lt;/P&gt;&lt;P&gt;set output&lt;/P&gt;&lt;P&gt;FILE FINALOP DLM='|' DSD;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; IF _N_ = 1 THEN DO;&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; &lt;/P&gt;&lt;P&gt;&amp;nbsp; PUT 'MCE_COMPANY_CODE|'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MCE_CONTRACT_SITUS_STATE|'&amp;nbsp; ,, remaining fileds.&lt;/P&gt;&lt;P&gt;-----&lt;/P&gt;&lt;P&gt;Pls advice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 15:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150669#M29713</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-11-24T15:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150670#M29714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the output file before the print, does it have the records?&lt;/P&gt;&lt;P&gt;Specifically in the outfile dataset&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 03:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150670#M29714</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-25T03:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150671#M29715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank so much.. I reviewed the code, found that there is a logic below which is removing these records. thanks thanks.. thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 08:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150671#M29715</guid>
      <dc:creator>veeru</dc:creator>
      <dc:date>2014-11-25T08:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: can we get below output with first. and last. or groupformat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150672#M29716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad you found your answer, but you really shouldn't mark yourself as providing the correct answer. &lt;/P&gt;&lt;P&gt;Several people provided the correct answer and hints. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 08:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-we-get-below-output-with-first-and-last-or-groupformat/m-p/150672#M29716</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-25T08:49:44Z</dc:date>
    </item>
  </channel>
</rss>

