<?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: Adding a date variable to a data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/874769#M345636</link>
    <description>&lt;P&gt;When there is an error in the log, show us the ENTIRE log for this data step. Do not show us part of the log. Do not show us only the errors. (And please don't make us ask for this repeatedly).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The WHERE statement cannot be used like that. According to the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/n1xbr9r0s9veq0n137iftzxq4g7e.htm#n1t8qo2qlsyhc3n17orioenneykj" target="_self"&gt;documentation&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The WHERE statement applies to all data sets in the preceding SET, MERGE, MODIFY, or UPDATE statement, and variables that are used in the WHERE statement must appear in all of those data sets. You cannot use the WHERE statement with the POINT= option in the SET and MODIFY statements.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your usage of WHERE does not meet the requirements stated. The variable TDAY is not a part of the variables in the preceding SET statement. So it can't be used like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if you replace WHERE with IF, then the code works.&lt;/P&gt;</description>
    <pubDate>Tue, 09 May 2023 21:16:17 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-05-09T21:16:17Z</dc:date>
    <item>
      <title>Adding a date variable to a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/874765#M345635</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;I have code below. I added tday to datasetp. It keeps saying that tday doesn't exist.&lt;/P&gt;
&lt;PRE&gt;data combo2;
tday = date();
format tday MMDDYY10.;
set combine;
where tday - someonedob &amp;lt;= 2;
run;&lt;BR /&gt;&lt;BR /&gt;Log:&lt;BR /&gt;ERROR: Variable tday is not on file WORK.COMB02.&lt;/PRE&gt;
&lt;P&gt;Any tip is greatly appreciated?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Blue blue&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 21:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/874765#M345635</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2023-05-09T21:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a date variable to a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/874769#M345636</link>
      <description>&lt;P&gt;When there is an error in the log, show us the ENTIRE log for this data step. Do not show us part of the log. Do not show us only the errors. (And please don't make us ask for this repeatedly).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The WHERE statement cannot be used like that. According to the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/n1xbr9r0s9veq0n137iftzxq4g7e.htm#n1t8qo2qlsyhc3n17orioenneykj" target="_self"&gt;documentation&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The WHERE statement applies to all data sets in the preceding SET, MERGE, MODIFY, or UPDATE statement, and variables that are used in the WHERE statement must appear in all of those data sets. You cannot use the WHERE statement with the POINT= option in the SET and MODIFY statements.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your usage of WHERE does not meet the requirements stated. The variable TDAY is not a part of the variables in the preceding SET statement. So it can't be used like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if you replace WHERE with IF, then the code works.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 21:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/874769#M345636</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-09T21:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a date variable to a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/875113#M345771</link>
      <description>&lt;P&gt;Hello Paige,&lt;/P&gt;
&lt;P&gt;It is acknowledged. I won't.&lt;/P&gt;
&lt;P&gt;I understand that we can't create a variable in a data step and then put where clause on that variable on the same data step. Is this what meant by this?&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;The WHERE statement applies to all data sets in the preceding SET, MERGE, MODIFY, or UPDATE statement, and variables that are used in the WHERE statement must appear in all of those data sets. You cannot use the WHERE statement with the POINT= option in the SET and MODIFY statements."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Blue&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 23:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/875113#M345771</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2023-05-10T23:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a date variable to a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/875144#M345783</link>
      <description>&lt;P&gt;The WHERE clause is applied as the data is read from the source dataset(s).&amp;nbsp; So you cannot reference variables in the WHERE statement that do not exist in the source dataset(s) &lt;STRONG&gt;because they don't exist!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 05:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-date-variable-to-a-data-step/m-p/875144#M345783</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-11T05:26:04Z</dc:date>
    </item>
  </channel>
</rss>

