<?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: Subsetting Dataset based on conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/538551#M148266</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards  truncover;
input ID    (ReportingDate   StartDate) (:date9.)  Value ;
format ReportingDate   StartDate date9.;	 
cards;
001   31Jan2018       31Jan2018   100
001   28Feb2018       31Jan2018   200
002   30Sep2016       28Feb2014   400
002   31Oct2016       28Feb2014   500
;

data want;
do until(last.id);
set have;
by id;
if first.id and  startdate&amp;gt;=reportingdate then f=1;
if f then output;
end;
drop f;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Feb 2019 04:22:04 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-02-26T04:22:04Z</dc:date>
    <item>
      <title>Subsetting Dataset based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/538548#M148264</link>
      <description>&lt;P&gt;i have a dataset of the following kind&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ID    ReportingDate   Start Date  Value
001   31Jan2018       31Jan2018   100
001   28Feb2018       31Jan2018   200
001   ....
002   30Sep2016       28Feb2014   400
002   31Oct2016       28Feb2014   500
002   ....&lt;/PRE&gt;&lt;P&gt;I need to create a condition such that only keep records with valid IDs where first instance of 'Start Date' is equal to or later than first instance of 'Reporting Date'. So essentially, ID 002 should not be kept in the dataset as the first Start Date is earlier than first Reporting Date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been fiddling around with first. but cannot get the condition to work. Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 03:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/538548#M148264</guid>
      <dc:creator>eemrun</dc:creator>
      <dc:date>2019-02-26T03:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Dataset based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/538550#M148265</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
infile cards  truncover;
input ID    (ReportingDate   StartDate) (:date9.)  Value ;
format ReportingDate   StartDate date9.;	 
cards;
001   31Jan2018       31Jan2018   100
001   28Feb2018       31Jan2018   200
002   30Sep2016       28Feb2014   400
002   31Oct2016       28Feb2014   500
;

proc sql;
create table want(drop=t) as
select *
from
(select * ,min(startdate)&amp;gt;=reportingdate as t from have group by id	)
group by id
having max(t)=1;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2019 03:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/538550#M148265</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-26T03:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Dataset based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/538551#M148266</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards  truncover;
input ID    (ReportingDate   StartDate) (:date9.)  Value ;
format ReportingDate   StartDate date9.;	 
cards;
001   31Jan2018       31Jan2018   100
001   28Feb2018       31Jan2018   200
002   30Sep2016       28Feb2014   400
002   31Oct2016       28Feb2014   500
;

data want;
do until(last.id);
set have;
by id;
if first.id and  startdate&amp;gt;=reportingdate then f=1;
if f then output;
end;
drop f;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2019 04:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/538551#M148266</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-26T04:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Dataset based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/539171#M148506</link>
      <description>perfect! thank you!</description>
      <pubDate>Wed, 27 Feb 2019 22:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subsetting-Dataset-based-on-conditions/m-p/539171#M148506</guid>
      <dc:creator>eemrun</dc:creator>
      <dc:date>2019-02-27T22:41:20Z</dc:date>
    </item>
  </channel>
</rss>

