<?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: If not SQL, then what? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126845#M25837</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a revised (one line changed) version of the code, that shows the value of days throughout the iterations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was simply looking for an algorithm that matched the days you had indicated were those needed to obtain the desired solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=DateCol Ontime--Four_days_late);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by datecol;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array dates(21);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array final(5) Ontime One_day_late Two_days_late Three_days_late Four_days_late;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain dates;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dates(cycle)=billcount;&lt;/P&gt;&lt;P&gt;&amp;nbsp; days=input(substr(strip(datecol),7,2),8.)+2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.datecol then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; days=ifn(days-1 eq 0,21,days-1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final(i)=days;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final(i)=dates(days);*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Sep 2012 01:09:12 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-09-21T01:09:12Z</dc:date>
    <item>
      <title>If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126833#M25825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings all.&amp;nbsp; I am trying to learn SAS programming, and I must say it has been very frustrating at times, but I'm starting to like it.&amp;nbsp; I've got sound SQL skills, so I found myself relying on proc sql as much as possible.&amp;nbsp; However, I feel that goes against the spirit of SAS, so I started trying to do things without SQL, and progress has been slow.&amp;nbsp; I've got one example I cannot even begin to fathom how to do without SQL, if anyone would be interested in giving it a whack.&amp;nbsp; My data are a company's billing cycle, and the number of bills that go out the door every day.&amp;nbsp; There are 21 billing cycles, and every customer account is put on one of them.&amp;nbsp; Every cycle has a schedule on which it will bill, and it is basically once per month, since bills don't go out on weekends.&amp;nbsp; Let's say today is the day for bill cycle 5 to send bills out.&amp;nbsp; I need to know how many bills went out the door on time, in addition to the number of bills that went out the door 1 to 4 days late.&amp;nbsp; A bill is late if it does not go out the door when it is supposed to.&amp;nbsp; So, if today is bill cycle 5, then all bills that should have gone out today, and did, are on time.&amp;nbsp; If a customer is on cycle 4, which should have gone out yesterday, but it went out today, then that bill is 1 day late.&amp;nbsp; I've attached a file that contains sample data, all the code, and a 'Final' result table that I make using proc sql.&amp;nbsp; Basically I'm just wondering how to go about producing dataset 'Final' without using any sql.&amp;nbsp; Any ideas would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 18:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126833#M25825</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-09-20T18:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126834#M25826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Seems to me 2XDOW will do the whack for ya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;until&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; (last.DateCol);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; datecol &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;notsorted&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; _ontime_cycle=ifn(ontime&amp;gt;= billcount, _ontime_cycle,cycle);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; ontime=ontime max BillCount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; _One_day_late_cycle=ifn(_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;,_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-abs(_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; _two_days_late_cycle=ifn( _ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;,_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-abs(_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; _three_days_late_cycle=ifn( _ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;,_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-abs(_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; _four_days_late_cycle=ifn( _ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;,_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-abs(_ontime_cycle-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;until&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; (last.DateCol);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; datecol &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;notsorted&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; cycle=_ontime_cycle &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; ontime=billcount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; cycle=_One_day_late_cycle &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; one_day_late=billcount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; cycle=_two_days_late_cycle &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; two_days_late=billcount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; cycle=_three_days_late_cycle &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; three_days_late=billcount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;else&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; cycle=_four_days_late_cycle &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; four_days_late=billcount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; _: billcount cycle;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, there are other data step approaches as well, such as stacking, hash() etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 19:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126834#M25826</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-09-20T19:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126835#M25827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another approach might be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=DateCol Ontime--Four_days_late);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by datecol;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array dates(21);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array final(5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain dates;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dates(cycle)=billcount;&lt;/P&gt;&lt;P&gt;&amp;nbsp; days=input(substr(strip(datecol),7,2),8.)+2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.datecol then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; days=ifn(days-1 eq 0,21,days-1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final(i)=dates(days);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ontime=final(1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; One_day_late=final(2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Two_days_late=final(3);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Three_days_late=final(4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Four_days_late=final(5);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 19:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126835#M25827</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-09-20T19:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126836#M25828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;WOW!&amp;nbsp; What can I say, other than I am floored at how easy you both made that look.&amp;nbsp; While messing with it I had probaly 200 lines of code that only got me about half way there.&amp;nbsp; My hat goes off to you, and you have inspired me to keep up the resistance to old habits.&amp;nbsp; Thank you both so, so much for your effort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 20:40:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126836#M25828</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-09-20T20:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126837#M25829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are some things that can be done better/more easily with sql, however datastep processing is definitely more suited for a number of tasks.&amp;nbsp; One should, me thinks, become adept at both.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW: I have absolutely no problem with your having marked Haikuo's solution as being correct, but if you have a large file, I would suggest actually using the code I suggested.&amp;nbsp; Haikuo's code requires reading the data twice, while the code I proposed, only makes a single pass through the data.&amp;nbsp; In short, it will likely take just half the time to complete the process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 21:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126837#M25829</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-09-20T21:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126838#M25830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Arthur, your solution seems so simple once I started looking at it, and it all makes sense except for one line.&amp;nbsp;&amp;nbsp; What is this doing...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; days=input(substr(strip(datecol),7,2),8.)+2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 21:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126838#M25830</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-09-20T21:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126839#M25831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai.kuo, what is 2XDOW, and I can't understand how the below line work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ontime=ontime max BillCount;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't get how the max in the middle is working.&amp;nbsp; Is it saying to keep the value of ontime unless it encounters a greater value of BillCount?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 21:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126839#M25831</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-09-20T21:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126840#M25832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I was updating my post, when you sent your question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I took the last two characters from your character string 'datecol' and created a variable that was equal to that number+2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For me, is was just a shortcut method of identifying where to start grabbing the desired data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e., days=&amp;nbsp; the value of the last two characters of 'datecol' (after removing any leading or trailing spaces), and adding the digit 2 to that number, using the input function to convert the result into a number.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 21:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126840#M25832</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-09-20T21:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126841#M25833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Regarding your question to Haikuo, take a look at:&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://support.sas.com/resources/papers/proceedings09/038-2009.pdf"&gt;http://support.sas.com/resources/papers/proceedings09/038-2009.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is simply a way to do things with a datastep above and beyond what one might pick up from the documentation.&amp;nbsp; Paul, the author of the paper I referenced, is one of three people who are credited with coming up with the idea.&amp;nbsp; It is commonly known as the Dorfman/Whitlock do loop or DOW for short.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Quite often, you can do something with a DOW loop, making 2 or 3 passes through the data, but without having to create additional files, or having to merge any files, to obtain a desired result.&amp;nbsp; It is a VERY useful technique to learn.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 21:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126841#M25833</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-09-20T21:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126842#M25834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Art, for answering for me.&lt;/P&gt;&lt;P&gt;OP, There is one thing I 'd like to address. There is a big difference between my approach and Art's. Mine was hinted by your code, first to check the largest billcount and use it as ontime. Art's approach, in my opinion, is more reasonable. He was using the date.&lt;/P&gt;&lt;P&gt;And Art's comment about performance is correct. However, if you are planning to do it my way, here is an improved version using array(), only one pass I/O:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; c(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;:&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;_temporary_&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; _n_=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;by&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;until&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; (last.DateCol);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; test ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; datecol cycle;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; c(_n_)=billcount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; _0=ifn(ontime&amp;gt;= billcount, _0,cycle);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; ontime=ontime max billcount;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; _1=ifn(_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;,_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-abs(_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; _2=ifn( _0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;,_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-abs(_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; _3=ifn(_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;,_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-abs(_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; _4=ifn( _0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;,_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;21&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-abs(_0-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; ontime=c(_0);one_day_late=c(_1);two_days_late=c(_2);three_days_late=c(_3);four_days_late=c(_4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; _: cycle;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 21:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126842#M25834</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-09-20T21:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126843#M25835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I liked Haikuo's revised version but, since he simplified his code, I'll do the same:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=DateCol Ontime--Four_days_late);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by datecol;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array dates(21);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array final(5) Ontime One_day_late Two_days_late Three_days_late Four_days_late;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain dates;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dates(cycle)=billcount;&lt;/P&gt;&lt;P&gt;&amp;nbsp; days=input(substr(strip(datecol),7,2),8.)+2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.datecol then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; days=ifn(days-1 eq 0,21,days-1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final(i)=dates(days);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 21:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126843#M25835</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-09-20T21:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126844#M25836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both so, so much for giving my issue such great care.&amp;nbsp; It will take some time for each solution to sink in, but I am eager to dive into it tomorrow.&amp;nbsp; I have a couple of questions if you would be so kind.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arthur: It seems that days is an arbitrary number based on the date in datecol, but I can't get what it is doing.&amp;nbsp; Why do you have to add 2?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo:&amp;nbsp; in your drop statement, you have '_:'&amp;nbsp; Does the colon after the underscore tell the processor to drop all variables starting with an underscore?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again, I am truly humbled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 00:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126844#M25836</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-09-21T00:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126845#M25837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a revised (one line changed) version of the code, that shows the value of days throughout the iterations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was simply looking for an algorithm that matched the days you had indicated were those needed to obtain the desired solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=DateCol Ontime--Four_days_late);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by datecol;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array dates(21);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array final(5) Ontime One_day_late Two_days_late Three_days_late Four_days_late;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain dates;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dates(cycle)=billcount;&lt;/P&gt;&lt;P&gt;&amp;nbsp; days=input(substr(strip(datecol),7,2),8.)+2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.datecol then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; days=ifn(days-1 eq 0,21,days-1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final(i)=days;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final(i)=dates(days);*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 01:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126845#M25837</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-09-21T01:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: If not SQL, then what?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126846#M25838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your guess is correct. For more information on colon (:), check this paper out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi26/p073-26.pdf" title="http://www2.sas.com/proceedings/sugi26/p073-26.pdf"&gt;http://www2.sas.com/proceedings/sugi26/p073-26.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 01:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-not-SQL-then-what/m-p/126846#M25838</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-09-21T01:14:00Z</dc:date>
    </item>
  </channel>
</rss>

