<?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 Print the Observations that Come after N dates? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231241#M42043</link>
    <description>&lt;P&gt;Here is a quickie, if you don't care about the row order,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
 select * from have
 group by id
 having date &amp;gt; min(date)
/*Order by date*/&lt;BR /&gt;;&lt;BR /&gt; quit;&lt;/PRE&gt;&lt;P&gt;You could&amp;nbsp;remove the comment, and&amp;nbsp;get something&amp;nbsp;identical to what you want, under the&amp;nbsp;assumption that your&amp;nbsp;original data was sorted by date.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Oct 2015 19:34:56 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2015-10-22T19:34:56Z</dc:date>
    <item>
      <title>How to Print the Observations that Come after N dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231238#M42042</link>
      <description>&lt;P&gt;This is along the same vein as: &lt;A href="https://communities.sas.com/t5/General-SAS-Programming/How-to-Print-Observations-that-Come-after-a-certain-number-of/m-p/196957" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/How-to-Print-Observations-that-Come-after-a-certain-number-of/m-p/196957&lt;/A&gt; (this addressed how to print observations that came after N numerical units).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm looking to print the observations that come after N distinct dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, I would want this data set to print out all observations above 1 &lt;EM&gt;&lt;STRONG&gt;distinct/unique&lt;/STRONG&gt;&lt;/EM&gt; date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data&amp;nbsp; have;
input id   date $  PaidAmount : dollar.;
format &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PaidAmount dollar.;
cards;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1/1/15&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $1000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1/1/15&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  $500
2           1/4/15         $300
2           1/5/15   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $2000
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1/6/15&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $0&lt;BR /&gt;1           1/2/15         $0&lt;BR /&gt;;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would want the following printed out:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;2           1/5/15   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $2000
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1/6/15&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $0&lt;BR /&gt;1           1/2/15         $0&lt;/PRE&gt;
&lt;P&gt;Thanks in advance for your help! &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 19:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231238#M42042</guid>
      <dc:creator>johnjinkim</dc:creator>
      <dc:date>2015-10-22T19:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to Print the Observations that Come after N dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231241#M42043</link>
      <description>&lt;P&gt;Here is a quickie, if you don't care about the row order,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
 select * from have
 group by id
 having date &amp;gt; min(date)
/*Order by date*/&lt;BR /&gt;;&lt;BR /&gt; quit;&lt;/PRE&gt;&lt;P&gt;You could&amp;nbsp;remove the comment, and&amp;nbsp;get something&amp;nbsp;identical to what you want, under the&amp;nbsp;assumption that your&amp;nbsp;original data was sorted by date.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 19:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231241#M42043</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-10-22T19:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to Print the Observations that Come after N dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231250#M42044</link>
      <description>&lt;P&gt;Hi mate,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the first. option to set the first occurency to flag = 1 or flag = "true"&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use the last. option to set the first occurency to flag = 1 or flag = "true":&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Do the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sort data=have;&lt;BR /&gt; by date;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt; set have;&lt;BR /&gt; by date;&lt;BR /&gt; if first.date then flg =1;&lt;BR /&gt; else flg=0;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want2;&lt;BR /&gt; set want;&lt;BR /&gt; where flg=1;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Att&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 19:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231250#M42044</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-10-22T19:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Print the Observations that Come after N dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231257#M42045</link>
      <description>&lt;P&gt;I think this is what you are looking for.&amp;nbsp; First, change your INPUT statement to convert dates properly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input id date : mmddyy8. PaidAmount : dollar.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then prepare a data set with the proper observations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by id date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by id date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if first.id then n_dates_found=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if first.date then n_dates_found + 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if n_dates_found &amp;gt; 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; format date mmddyys10.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The order would change ... the data set is now in order by ID.&amp;nbsp; Does that represent a problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On another note, I would recommend using four-digit years if at all possible.&amp;nbsp; Depending on the range of your dates, two-digit years risk SAS assigning the wrong century to your dates.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 20:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231257#M42045</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-10-22T20:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Print the Observations that Come after N dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231626#M42162</link>
      <description>&lt;P&gt;Exactly what I was looking for! Thanks to everyone for your feedback as it gave me much more insight into the various solutions. Apologies for any clarity issues on my end.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 13:51:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Print-the-Observations-that-Come-after-N-dates/m-p/231626#M42162</guid>
      <dc:creator>johnjinkim</dc:creator>
      <dc:date>2015-10-26T13:51:22Z</dc:date>
    </item>
  </channel>
</rss>

