<?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 output the last part (data programming) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510197#M137293</link>
    <description>&lt;P&gt;&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; understood.&amp;nbsp; Have one on me and I will pay for it in the next life if we get one and if not then at least you had another reason to have one.&amp;nbsp; Bottoms&lt;/P&gt;</description>
    <pubDate>Sat, 03 Nov 2018 18:26:25 GMT</pubDate>
    <dc:creator>VDD</dc:creator>
    <dc:date>2018-11-03T18:26:25Z</dc:date>
    <item>
      <title>How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510172#M137279</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I need some help here &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is the question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas111.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24627i92160C1B28F30578/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas111.PNG" alt="sas111.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas11.PNG" style="width: 415px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24626iA5DE4947BC9D1CB5/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas11.PNG" alt="sas11.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Write a SAS program that reads each record of SalesRecords.txt into a SAS data set named Sales_Total. Sales_Total must be in the following form:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;It contains&lt;STRONG&gt; only one observation for each salesperson&lt;/STRONG&gt;. &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Each observation contains only the following variables in this order: the salesperson’s name, the salesperson’s latest sales date, the number of days between the salesperson’s latest sales date and the 30th of September 2018, the salesperson’s total sales, and the running total of sales for all salespersons. &lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You are allowed to include &lt;STRONG&gt;only one DATA step&lt;/STRONG&gt; in your SAS program. Keep in mind that some salespersons in the raw data file may have only 1 record, and the records of the same salespersons are not sorted in the order of date. The first few observations of Sales_Total are displayed below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas1111.PNG" style="width: 482px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24628iF04377CC85BDA45D/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas1111.PNG" alt="sas1111.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The labels shown in the above Sales_Total are for reference only. You don’t need to define them in your SAS DATA step program. You may name the variables in any way you want as long as they are valid SAS variable names."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I am only able to do the following. I do not know how to output the last part (last photo), such as combining the total sales and the latest sales date, etc..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data &lt;SPAN&gt;Sales_Total;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;infile &lt;SPAN&gt;'c:\temp\SalesRecords.txt’;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;input salesname &amp;amp; $1-15 salesdate date11. 16-26 salesamt 28-32;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 15:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510172#M137279</guid>
      <dc:creator>kennyA</dc:creator>
      <dc:date>2018-11-03T15:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510177#M137282</link>
      <description>&lt;P&gt;Since this is the third post with the same identical question, use the search function here.&lt;/P&gt;
&lt;P&gt;And it should return the one question right before yours:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Creating-variables-from-existing-variables/m-p/510163" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Creating-variables-from-existing-variables/m-p/510163&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 15:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510177#M137282</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-03T15:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510180#M137284</link>
      <description>&lt;P&gt;&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://communities.sas.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;&amp;nbsp; chasing managers bits and pieces leads to confusion.&amp;nbsp; Please ask everything in one post.&amp;nbsp; Time wasted is never retrievable but data is. &amp;nbsp;&lt;img id="robotmad" class="emoticon emoticon-robotmad" src="https://communities.sas.com/i/smilies/16x16_robot-mad.png" alt="Robot Mad" title="Robot Mad" /&gt; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 15:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510180#M137284</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-03T15:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510181#M137285</link>
      <description>sorry &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;I didnt notice it but I think my post is clearer in terms of the requirements</description>
      <pubDate>Sat, 03 Nov 2018 15:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510181#M137285</guid>
      <dc:creator>kennyA</dc:creator>
      <dc:date>2018-11-03T15:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510189#M137287</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm log 'clear';
data _null_;
infile datalines firstobs=2 eof=l ;
input name $ 1-15 lt_sales_date :date11. person_total_sales 28-32;
if _n_=1 then do;
  dcl hash H () ;
   h.definekey  ("name") ;
   h.definedata ("name","latest_sales_date","daysdiff", "salep_tot","running_tot") ;
   h.definedone () ;
end;
retain _n latest_sales_date  running_tot ;
if not missing(name) then _n=name;
else name=_n;
if lag(name) ne name then do;
salep_tot=person_total_sales;
latest_sales_date=lt_sales_date;
end;
else do;
salep_tot+person_total_sales;
latest_sales_date=max(lt_sales_date,latest_sales_date);
end;
daysdiff='30sep2018'd-latest_sales_date;
running_tot+person_total_sales;
h.replace();
return;
l:
h.output(dataset:'want');
datalines;
1234567890123456789012345678901234567890
David Wong     1/Aug/2018  13200 
Brian Leung    15/Sep/2018 23450
               10/Sep/2018 33000
Mary Chan      3/Jul/2018  45600
               20/Aug/2018 37800
               1/Sep/2018  21500
               30/Aug/2018 42000
John Tam       12/Sep/2018 35000
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Nov 2018 17:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510189#M137287</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-03T17:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510191#M137288</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/243976"&gt;@kennyA&lt;/a&gt;&amp;nbsp;Are you and the other thread&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Creating-variables-from-existing-variables/m-p/510174#M137281&amp;nbsp;" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Creating-variables-from-existing-variables/m-p/510174#M137281&amp;nbsp;&lt;/A&gt; author blowsnow__&amp;nbsp; &amp;nbsp;the same or mates by any chance?. Of course, not my business or concern,but the questions are so identical, so was curious.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyways, if it's hw, I wouldn't class that as easy or even medium for new users if they are just average like me coz unless one knows about techniques like look above/look ahead the stated condition-"&lt;SPAN&gt;You are allowed to include&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;only one DATA step&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;in your SAS program" poses a significant challenge for new to intermediate users in my humble opinion&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 17:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510191#M137288</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-03T17:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510193#M137289</link>
      <description>&lt;P&gt;Thanks for the suggestion! And to answer your curiosity, the author and I should be mates if I'm not mistaken.&amp;nbsp;&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://communities.sas.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, for the output table, is there any&amp;nbsp;methods to rearrange the order so that it looks the same as shown in the requirements above?&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 18:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510193#M137289</guid>
      <dc:creator>blowsnow__</dc:creator>
      <dc:date>2018-11-03T18:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510194#M137290</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; hats off to you. &amp;nbsp;&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;I was having an issue with calculating the days and keep getting over the expected number of days in my output.&lt;/P&gt;
&lt;P&gt;Your code is great and if you don't mind I would like to keep it and use for other to learn from in future demonstrations. &amp;nbsp;&lt;img id="heart" class="emoticon emoticon-heart" src="https://communities.sas.com/i/smilies/16x16_heart.png" alt="Heart" title="Heart" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 18:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510194#M137290</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-03T18:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510195#M137291</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244119"&gt;@blowsnow__&lt;/a&gt;&amp;nbsp; Good mates eh? LOL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here you go:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm log 'clear';
data _null_;
infile datalines firstobs=2 eof=l ;
input name $ 1-15 lt_sales_date :date11. person_total_sales 28-32;
if _n_=1 then do;
  dcl hash H (ordered:'y') ;
   h.definekey  ("n","name") ;
   h.definedata ("name","latest_sales_date","daysdiff", "salep_tot","running_tot") ;
   h.definedone () ;
end;
retain _n latest_sales_date  running_tot ;
if not missing(name) then _n=name;
else name=_n;
if lag(name) ne name then do;
salep_tot=person_total_sales;
latest_sales_date=lt_sales_date;
n+1;
end;
else do;
salep_tot+person_total_sales;
latest_sales_date=max(lt_sales_date,latest_sales_date);
end;
daysdiff='30sep2018'd-latest_sales_date;
running_tot+person_total_sales;
h.replace();
return;
l:
h.output(dataset:'want');
datalines;
1234567890123456789012345678901234567890
David Wong     1/Aug/2018  13200 
Brian Leung    15/Sep/2018 23450
               10/Sep/2018 33000
Mary Chan      3/Jul/2018  45600
               20/Aug/2018 37800
               1/Sep/2018  21500
               30/Aug/2018 42000
John Tam       12/Sep/2018 35000
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Nov 2018 18:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510195#M137291</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-03T18:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510196#M137292</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Your code is great and if you don't mind I would like to keep it and use for other to learn from in future demonstrations"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp; to your &lt;EM&gt;&lt;STRONG&gt;"if you don't mind"&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;hahahahahaha You made my weekend. I still am hung over from last night. I will have few more tonight&amp;nbsp; .lol&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Come on!, none of us own any of the codes once it is posted online in a forum like this. If we start requesting like this, how many&amp;nbsp;times- "if you don't mind" should i iterate to people like John King,Mark Keintz, Art T, PGstats, PD, Ksharp, Reeza , Freelancereinhard etc:)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 18:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510196#M137292</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-03T18:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510197#M137293</link>
      <description>&lt;P&gt;&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; understood.&amp;nbsp; Have one on me and I will pay for it in the next life if we get one and if not then at least you had another reason to have one.&amp;nbsp; Bottoms&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 18:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510197#M137293</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-03T18:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510198#M137294</link>
      <description>&lt;P&gt;Just to thank you on a &lt;U&gt;"healthy"&lt;/U&gt; note, I was really dull, weak and tired but that message of yours charged me up truly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 18:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510198#M137294</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-03T18:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510217#M137311</link>
      <description>Just an FYI, If your course has not covered hash and you submit a hash solution....</description>
      <pubDate>Sun, 04 Nov 2018 01:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510217#M137311</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-04T01:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510223#M137314</link>
      <description>&lt;P&gt;Although &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;'s hash object solution is neat, you can solve this problem just by wallowing around in basic early SAS, utilizing some of the power of the INPUT statement, especially the trailing @, trailing @@, and the record advance character '/':&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=_:);
  infile 'c:\temp\salesrecords.txt' end=end_of_data;
  input @1 name $char13. @ ;

  do until (_nxt_name^=' ');
    input _date :date11. _sales @;
    latest_sales_date=max(latest_sales_date,_date);
    ndays='30sep2018'd-latest_sales_date;
    personal_total=sum(personal_total,_sales);
    running_total+_sales;
    if end_of_data=0 then input / @1 _nxt_name $char13. @@;
    else _nxt_name='ZZZ';
  end;
  format latest_sales_date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Trailing @ means hold the pointer, such that the next INPUT statement starts where the pointer is held.&amp;nbsp; But don't hold the pointer across data step iterations (of which there are 4 - one per sales person).&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Within each data step iteration (i.e. each sales person), loop through records&amp;nbsp;until the name in the following record is not blank.&amp;nbsp; If the current record is the end of file, then synthetically assign a non-blank so the next name.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;"personal_total=sum(personal_total,sales) will
&lt;OL&gt;
&lt;LI&gt;treat a missing value for personal_total as a zero, and&lt;/LI&gt;
&lt;LI&gt;personal_total is initialized to missing when the next data step iteration begins.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;running_total+sales;&amp;nbsp;&amp;nbsp; keeps a running total and never resets it to missing.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The "if end_of_data=0" statement
&lt;OL&gt;
&lt;LI&gt;tells sas to advance one record to read the next name (to see whether it is blank).&lt;/LI&gt;
&lt;LI&gt;The trailing "@@" says to hold the pointer tightly.&amp;nbsp; I.e. even when the data step goes to the next iteration (next sales person) the record is not thrown away, and therefore will supply the next actual name with the input statement.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 04 Nov 2018 05:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510223#M137314</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-11-04T05:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510232#M137321</link>
      <description>&lt;P&gt;Much appreciated for the thorough explanation! But when I try to run the program, however, the output is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture.PNG" style="width: 509px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24633i498D85E91B0B35F3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get rid of the first line from the data set and replace it with the person "David Wong" instead?&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 08:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510232#M137321</guid>
      <dc:creator>blowsnow__</dc:creator>
      <dc:date>2018-11-04T08:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to output the last part (data programming)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510233#M137322</link>
      <description>Never mind, I added firstob=2 in my infile statement and it works. Thanks again for your detail explanation!</description>
      <pubDate>Sun, 04 Nov 2018 08:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-the-last-part-data-programming/m-p/510233#M137322</guid>
      <dc:creator>blowsnow__</dc:creator>
      <dc:date>2018-11-04T08:56:03Z</dc:date>
    </item>
  </channel>
</rss>

