<?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: How to get rid of the last record while reading a file in SAS DI studio in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213119#M5043</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same as &lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; suggests: Add to the infile options in the external metadata something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end=last;&lt;/P&gt;&lt;P&gt;input @;&lt;/P&gt;&lt;P&gt;if _n_=1 or last then return;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jul 2015 07:53:32 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-07-13T07:53:32Z</dc:date>
    <item>
      <title>How to get rid of the last record while reading a file in SAS DI studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213113#M5037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SAS,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish to know what is the procedure and the transformation to be used to get rid of the last record. Suppose, there is a dummy record in the last observation and I want to get rid of it using a transformation.&lt;/P&gt;&lt;P&gt;Ex: out of 11 recrods, the last is found to be dummy and I want to read only first 10 records..(using transformation and no user written code)Di&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2015 17:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213113#M5037</guid>
      <dc:creator>Buddu</dc:creator>
      <dc:date>2015-06-24T17:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get rid of the last record while reading a file in SAS DI studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213114#M5038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Moved this into &lt;A __default_attr="59" __jive_macro_name="community" class="jive_macro jive_macro_community" href="https://communities.sas.com/" modifiedtitle="true" title="Data Management "&gt;&lt;/A&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;for more attention by the experts.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2015 16:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213114#M5038</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2015-06-29T16:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get rid of the last record while reading a file in SAS DI studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213115#M5039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming we're talking about external data (eg. a text file) and not a table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First question: What constitutes a dummy record? Let's assume this is a record with no data (just an empty line). So writing SAS code you could code something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile blah;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; input @;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; if missing(_infile_) then return;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input a b c;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;You can "force" DI to generate such code by "injecting" it using the External File Metadata Definition under "File Parameter / Advanced"&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image" src="https://communities.sas.com/legacyfs/online/11035_Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will generate the "infile" statement as follows:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image" src="https://communities.sas.com/legacyfs/online/11036_Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;So basically above approach allows you to "inject" any code between the generated INFILE and INPUT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this solve your problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2015 10:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213115#M5039</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-06-30T10:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get rid of the last record while reading a file in SAS DI studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213116#M5040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Neat way to insert user written code in the external file &lt;A __default_attr="12296" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;, never thought of this &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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2015 10:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213116#M5040</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-06-30T10:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to get rid of the last record while reading a file in SAS DI studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213117#M5041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This did help and yes the file is a .txt. However, dummy means that it has data but cannot be processed further, the entire records needs to be dropped. &lt;/P&gt;&lt;P&gt;After I read the file successfully using the file reader, I make use of slitter to hard code the value present in the variable in row selection&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="sasq.JPG" class="jive-image" src="https://communities.sas.com/legacyfs/online/11134_sasq.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish to know is there a workaround to strip first and last records. Just like first.variable and last.variable in datastep. The variable here is Mortgage... and if I wish to strip the first header record - I make use of _N_ ~= 1, similarly, I wish to know how to strip the last record of the file rather than hard coding to value or like operator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jul 2015 22:05:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213117#M5041</guid>
      <dc:creator>Buddu</dc:creator>
      <dc:date>2015-07-12T22:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get rid of the last record while reading a file in SAS DI studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213118#M5042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Uaing end= infile option instead and use that for the if statement. Untested...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 04:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213118#M5042</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-07-13T04:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to get rid of the last record while reading a file in SAS DI studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213119#M5043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same as &lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; suggests: Add to the infile options in the external metadata something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end=last;&lt;/P&gt;&lt;P&gt;input @;&lt;/P&gt;&lt;P&gt;if _n_=1 or last then return;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 07:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-get-rid-of-the-last-record-while-reading-a-file-in-SAS-DI/m-p/213119#M5043</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-07-13T07:53:32Z</dc:date>
    </item>
  </channel>
</rss>

