<?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 Read the last record of csv file in another dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398916#M96549</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the&amp;nbsp;attached raw&amp;nbsp;file on a unix server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alfred|14|M|69|112.5&lt;BR /&gt;Alice|13|F|56.5|84&lt;BR /&gt;Barbara|13|F|65.3|98&lt;BR /&gt;Carol|14|F|62.8|102.5&lt;BR /&gt;.(MORE RECORDS).&lt;/P&gt;
&lt;P&gt;Thomas|11|M|57.5|85&lt;BR /&gt;William|15|M|66.5|112&lt;BR /&gt;87654321&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to read the file completely but the last record is the observation count of the file given by source.&lt;/P&gt;
&lt;P&gt;I have to read this LAST number in another file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should i do that?Attached is a test file for reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Here is what i need:&amp;nbsp;&lt;/STRONG&gt;2 datasets.&lt;/P&gt;
&lt;P&gt;1 with regular input of all variables.&lt;/P&gt;
&lt;P&gt;and other with just one obervation and one variable having the last record of count i.e.--"87654321"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2017 19:34:52 GMT</pubDate>
    <dc:creator>ArpitSharma</dc:creator>
    <dc:date>2017-09-26T19:34:52Z</dc:date>
    <item>
      <title>Read the last record of csv file in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398916#M96549</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the&amp;nbsp;attached raw&amp;nbsp;file on a unix server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alfred|14|M|69|112.5&lt;BR /&gt;Alice|13|F|56.5|84&lt;BR /&gt;Barbara|13|F|65.3|98&lt;BR /&gt;Carol|14|F|62.8|102.5&lt;BR /&gt;.(MORE RECORDS).&lt;/P&gt;
&lt;P&gt;Thomas|11|M|57.5|85&lt;BR /&gt;William|15|M|66.5|112&lt;BR /&gt;87654321&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to read the file completely but the last record is the observation count of the file given by source.&lt;/P&gt;
&lt;P&gt;I have to read this LAST number in another file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should i do that?Attached is a test file for reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Here is what i need:&amp;nbsp;&lt;/STRONG&gt;2 datasets.&lt;/P&gt;
&lt;P&gt;1 with regular input of all variables.&lt;/P&gt;
&lt;P&gt;and other with just one obervation and one variable having the last record of count i.e.--"87654321"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398916#M96549</guid>
      <dc:creator>ArpitSharma</dc:creator>
      <dc:date>2017-09-26T19:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Read the last record of csv file in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398926#M96555</link>
      <description>&lt;P&gt;It's not difficult, but it's not clear either.&amp;nbsp; Try taking the small amount of data shown in your post, and sketch out what you would like the result to be.&amp;nbsp; Be sure to indicate what is a SAS data set and what is a text file.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398926#M96555</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-26T19:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Read the last record of csv file in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398927#M96556</link>
      <description>&lt;P&gt;If you can read this file properly including the last row ... then just modify the code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one two;
     infile filename end=eof;
     .... statements to read data ....
     if not eof then output one;
     else output two;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398927#M96556</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-09-26T19:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Read the last record of csv file in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398932#M96557</link>
      <description>&lt;P&gt;To expand on &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;'s proposal, I'd do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data
  one (drop=reccount)
  two (keep=reccount)
,
infile "xxx.txt" end=eof;
if eof
then do;
  input reccount;
  output two;
end;
else do;
  input /* your variables */;
  output one;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This also solves the problem of different line layouts.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398932#M96557</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-26T19:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read the last record of csv file in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398933#M96558</link>
      <description>&lt;P&gt;Do something like this perhaps?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename tst temp;
data _null_;
  file tst;
  input;
  put _infile_;
cards;
Alfred|14|M|69|112.5
Alice|13|F|56.5|84
Barbara|13|F|65.3|98
Carol|14|F|62.8|102.5
Thomas|11|M|57.5|85
William|15|M|66.5|112
6
;

data want(drop=nobs) nobs(keep=nobs);
  infile tst dsd dlm='|' truncover end=eof ;
  input @;
  if eof then do;
    input nobs;
    output nobs;
    if nobs ne _n_-1 then put
      'WARNING: Record count missmatch. ' (_n_ nobs) (= :comma20. +1)
    ;
  end;
  else do;
    length name $20 age 8 sex $1 height weight 8 ;
    input name -- weight ;
    output want ;
  end;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; NOTE: 7 records were read from the infile TST.
       The minimum record length was 80.
       The maximum record length was 80.
 NOTE: The data set WORK.WANT has 6 observations and 5 variables.
 NOTE: The data set WORK.NOBS has 1 observations and 1 variables.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398933#M96558</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-26T19:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Read the last record of csv file in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398936#M96559</link>
      <description>&lt;P&gt;The&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input @;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is the key.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 19:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-the-last-record-of-csv-file-in-another-dataset/m-p/398936#M96559</guid>
      <dc:creator>ArpitSharma</dc:creator>
      <dc:date>2017-09-26T19:57:47Z</dc:date>
    </item>
  </channel>
</rss>

