<?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 If Date1 is not equal to Date2, print &amp;quot;BAD&amp;quot; in Date2. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601711#M16754</link>
    <description>&lt;P&gt;data date;&lt;/P&gt;&lt;P&gt;input date1 date2;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;25000 25000&lt;/P&gt;&lt;P&gt;25010 25000&lt;/P&gt;&lt;P&gt;25150 25150&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to use &lt;STRONG&gt;proc format&lt;/STRONG&gt; or &lt;STRONG&gt;another method&lt;/STRONG&gt; to print If date1 is not equal to date2, print "BAD" in date2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can I do with this situation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your assistance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Nov 2019 17:06:20 GMT</pubDate>
    <dc:creator>Thanyada</dc:creator>
    <dc:date>2019-11-05T17:06:20Z</dc:date>
    <item>
      <title>If Date1 is not equal to Date2, print "BAD" in Date2.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601711#M16754</link>
      <description>&lt;P&gt;data date;&lt;/P&gt;&lt;P&gt;input date1 date2;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;25000 25000&lt;/P&gt;&lt;P&gt;25010 25000&lt;/P&gt;&lt;P&gt;25150 25150&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to use &lt;STRONG&gt;proc format&lt;/STRONG&gt; or &lt;STRONG&gt;another method&lt;/STRONG&gt; to print If date1 is not equal to date2, print "BAD" in date2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can I do with this situation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your assistance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 17:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601711#M16754</guid>
      <dc:creator>Thanyada</dc:creator>
      <dc:date>2019-11-05T17:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: If Date1 is not equal to Date2, print "BAD" in Date2.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601716#M16755</link>
      <description>&lt;P&gt;Since Date1 and Date2 are date fields (numeric) you're going to have trouble printing "BAD" within the column Date2. You might try something like proc format on the difference? Format the value of 0 as "BAD". But either way you do it you're output will need to be in a character column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-unison&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 17:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601716#M16755</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-05T17:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: If Date1 is not equal to Date2, print "BAD" in Date2.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601718#M16756</link>
      <description>&lt;P&gt;A format, whether from the SAS format library, or defined by a user can only be assigned to a variable, not to a combination of variables.&amp;nbsp; So you would have to make a new variable signaling whether DATE1=DATE2.&amp;nbsp; And if that is the case, you could assign that new variables a character value of 'BAD'&amp;nbsp; or 'GOOD', and thereby avoid the need for a format entirely. &amp;nbsp; I.e. making a new variable is the "another method" that I would suggest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do this in a DATA step, with an IF test on the equality of date1 and date2, containing a THEN clause that conditionally assigns the desired value.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 17:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601718#M16756</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-05T17:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: If Date1 is not equal to Date2, print "BAD" in Date2.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601797#M16769</link>
      <description>&lt;P&gt;With existing numeric date values then one approach to achieve your goal is to 1) assign a "special" value to the date2 variable and 2) have a custom format to display the desired text. One way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
   value baddate
   .B='Bad Date'
   other = [date9.]
   ;
run;
data have;
   input date1 date2;
   if date1 ne date2 then date2=.B;
   format date1 date9.  date2 baddate.;
datalines;
25000 25000
25010 25000
25150 25150
;
proc print data=have;
run;&lt;/PRE&gt;
&lt;P&gt;The .B is a "special missing" value. SAS allows 27 special missing values&amp;nbsp;._ and .A through .Z. The special missing do not get used as numeric values like normal missing but you can have different display values to display different results for special cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 20:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Date1-is-not-equal-to-Date2-print-quot-BAD-quot-in-Date2/m-p/601797#M16769</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-05T20:47:29Z</dc:date>
    </item>
  </channel>
</rss>

