<?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 Computed column comparing date column to today() in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747065#M38910</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm very new to SAS and I'm trying to compute a column in a report that generates a text string based on a comparison of the ENDDATE column to today(). I must have an error, because the computed column consistently returns 'Closed' even for dates &amp;gt;= today(). Help is appreciated! Here is what I've gotten so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc Report data=outbreaks;&lt;BR /&gt;Column OUTBREAKNAME ONSET ENDDATE STATUS;&lt;BR /&gt;Define OUTBREAKNAME /group 'Outbreak Name';&lt;BR /&gt;Define ONSET /analysis min 'Start Date';&lt;BR /&gt;Define ENDDATE /analysis max 'End Date';&lt;BR /&gt;Define STATUS / computed 'Status';&lt;BR /&gt;Title 'Outbreak Status';&lt;BR /&gt;Compute STATUS / char length=20;&lt;BR /&gt;If ENDDATE &amp;gt;= today()&lt;BR /&gt;then STATUS= 'Active / Ongoing';&lt;BR /&gt;Else STATUS= 'Closed';&lt;BR /&gt;Endcomp&lt;BR /&gt;Run;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jun 2021 15:52:46 GMT</pubDate>
    <dc:creator>SASbeginnerEPI</dc:creator>
    <dc:date>2021-06-10T15:52:46Z</dc:date>
    <item>
      <title>Computed column comparing date column to today()</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747065#M38910</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm very new to SAS and I'm trying to compute a column in a report that generates a text string based on a comparison of the ENDDATE column to today(). I must have an error, because the computed column consistently returns 'Closed' even for dates &amp;gt;= today(). Help is appreciated! Here is what I've gotten so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc Report data=outbreaks;&lt;BR /&gt;Column OUTBREAKNAME ONSET ENDDATE STATUS;&lt;BR /&gt;Define OUTBREAKNAME /group 'Outbreak Name';&lt;BR /&gt;Define ONSET /analysis min 'Start Date';&lt;BR /&gt;Define ENDDATE /analysis max 'End Date';&lt;BR /&gt;Define STATUS / computed 'Status';&lt;BR /&gt;Title 'Outbreak Status';&lt;BR /&gt;Compute STATUS / char length=20;&lt;BR /&gt;If ENDDATE &amp;gt;= today()&lt;BR /&gt;then STATUS= 'Active / Ongoing';&lt;BR /&gt;Else STATUS= 'Closed';&lt;BR /&gt;Endcomp&lt;BR /&gt;Run;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 15:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747065#M38910</guid>
      <dc:creator>SASbeginnerEPI</dc:creator>
      <dc:date>2021-06-10T15:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column comparing date column to today()</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747068#M38911</link>
      <description>&lt;P&gt;Data is nice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I make dummy set to check your code:&lt;/P&gt;
&lt;PRE&gt;data junk;
   enddate = '31DEC9999'd;
run;

proc report data=junk;
   columns enddate status;
   Define ENDDATE /analysis max 'End Date';
   Define STATUS / computed 'Status';
   Compute STATUS / char length=20;
      If ENDDATE &amp;gt;= today()
      then STATUS= 'Active / Ongoing';
      Else STATUS= 'Closed';
   Endcomp ;
Run;&lt;/PRE&gt;
&lt;P&gt;The log shows:&lt;/P&gt;
&lt;PRE&gt;21   proc report data=junk;
22      columns enddate status;
23      Define ENDDATE /analysis max 'End Date';
24      Define STATUS / computed 'Status';
25      Compute STATUS / char length=20;
26         If ENDDATE &amp;gt;= today()
27         then STATUS= 'Active / Ongoing';
28         Else STATUS= 'Closed';
29      Endcomp ;
30   Run;

NOTE: Variable ENDDATE is uninitialized.
NOTE: There were 1 observations read from the data set WORK.JUNK.
NOTE: PROCEDURE REPORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;You did read the log didn't you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the difference below.&lt;/P&gt;
&lt;PRE&gt;32   proc report data=junk;
33      columns enddate status;
34      Define ENDDATE /analysis max 'End Date';
35      Define STATUS / computed 'Status';
36      Compute STATUS / char length=20;
37         If ENDDATE&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;.max&lt;/STRONG&gt;&lt;/FONT&gt; &amp;gt;= today()
38         then STATUS= 'Active / Ongoing';
39         Else STATUS= 'Closed';
40      Endcomp ;
41   Run;

NOTE: There were 1 observations read from the data set WORK.JUNK.
NOTE: PROCEDURE REPORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

&lt;/PRE&gt;
&lt;P&gt;There are times you have to reference the statistic of a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 16:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747068#M38911</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-10T16:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column comparing date column to today()</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747073#M38912</link>
      <description>&lt;P&gt;Thank you! That solved it. I did read the log, but I admit I'm still learning HOW to read the log and make sense of it. I really appreciate the quick response and solution.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 16:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747073#M38912</guid>
      <dc:creator>SASbeginnerEPI</dc:creator>
      <dc:date>2021-06-10T16:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Computed column comparing date column to today()</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747137#M38913</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/385346"&gt;@SASbeginnerEPI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you! That solved it. I did read the log, but I admit I'm still learning HOW to read the log and make sense of it. I really appreciate the quick response and solution.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The clue in this case from the log was the "uninitialized". SAS uses that when a variable exists but a value has not been assigned.&lt;/P&gt;
&lt;P&gt;Since the variable exists and has values, what would be "uninitialized" is the question. So we look at how the variable is used and the Analysis gives us a clue that the statistic may be wanted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 16:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Computed-column-comparing-date-column-to-today/m-p/747137#M38913</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-10T16:53:49Z</dc:date>
    </item>
  </channel>
</rss>

