<?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: Reference the date of another var in conditional in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521793#M141596</link>
    <description>&lt;P&gt;In order to be able to work with dates, they must be read in using the proper informat to make them dates and not text.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST;
    INPUT ID DATA_VALID date9. ID_YEAR;
DATALINES;
1 01APR2012 2013
2 14DEC2014 2015
2 27AUG2010 2009
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then to do the comparison&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT;
    SET TEST;
    IF DATA_VALID &amp;gt;  mdy(12,31,id_year) THEN flag= 1;
        ELSE flag=0;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 16 Dec 2018 14:25:16 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-12-16T14:25:16Z</dc:date>
    <item>
      <title>Reference the date of another var in conditional</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521792#M141595</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create an exclusion criteria using the years within a variable. The data looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST;
    INPUT ID DATA_VALID ID_YEAR;
DATALINES;
1 01APR2012 2013
2 14DEC2014 2015
2 27AUG2010 2009
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to perform the logical statement: If the DATA_VALID observation is after the ID_YEAR observation of December 31 YYYY, flag it as a 0.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT:
    SET TEST;
    IF DATA_VALID &amp;gt;  '31DEC+"ID_YEAR"'d THEN flag= 1;
        ELSE flag=0;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The first two observations should be set to 0, with the last (ID=3) equal to 1.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2018 14:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521792#M141595</guid>
      <dc:creator>MB_Analyst</dc:creator>
      <dc:date>2018-12-16T14:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: Reference the date of another var in conditional</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521793#M141596</link>
      <description>&lt;P&gt;In order to be able to work with dates, they must be read in using the proper informat to make them dates and not text.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST;
    INPUT ID DATA_VALID date9. ID_YEAR;
DATALINES;
1 01APR2012 2013
2 14DEC2014 2015
2 27AUG2010 2009
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then to do the comparison&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT;
    SET TEST;
    IF DATA_VALID &amp;gt;  mdy(12,31,id_year) THEN flag= 1;
        ELSE flag=0;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Dec 2018 14:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521793#M141596</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-16T14:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reference the date of another var in conditional</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521795#M141597</link>
      <description>&lt;P&gt;Why make it complex?&amp;nbsp; Why not:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if year(date_valid) &amp;gt; id_year then flag=1;&lt;/P&gt;
&lt;P&gt;else flag=0;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2018 15:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521795#M141597</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-16T15:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reference the date of another var in conditional</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521797#M141598</link>
      <description>&lt;P&gt;Or even shorter:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;flag = year(date_valid) &amp;gt; id_year;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Dec 2018 15:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reference-the-date-of-another-var-in-conditional/m-p/521797#M141598</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-16T15:39:04Z</dc:date>
    </item>
  </channel>
</rss>

