<?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: %let macro date as date value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732835#M228362</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=p1d9ypna2tpt16n1xam57kuffcpt.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;%SYSEVALF macro function&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_SAS=%sysevalf('25AUG2020'd);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 11 Apr 2021 09:09:19 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-04-11T09:09:19Z</dc:date>
    <item>
      <title>%let macro date as date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732831#M228360</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;What is the way to define a macro variable with a numerical date value?&lt;/P&gt;
&lt;P&gt;In this case I need that SAS define macro variable&amp;nbsp;&lt;CODE class=" language-sas"&gt;start_SAS as&amp;nbsp;value&amp;nbsp;22152&amp;nbsp;(Because&amp;nbsp;22152&amp;nbsp;is&amp;nbsp;the&amp;nbsp;numerical&amp;nbsp;value&amp;nbsp;of&amp;nbsp;25AUG2020)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;What is the way to define it via %let please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_SAS='25AUG2020';
%put &amp;amp;start_SAS;

data ttt;
input x : date9.;
cards;
'20AUG2020'
'30AUG2020'
;
Run;

PROC SQL;
	create table tbl  as
	select * 	   
	from ttt 
	where x&amp;gt;&amp;amp;start_SAS.
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 08:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732831#M228360</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-04-11T08:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: %let macro date as date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732834#M228361</link>
      <description>&lt;P&gt;I know that I can write&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_SAS="25AUG2020"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I prefer to see the real numeric value of the sas date .&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 08:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732834#M228361</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-04-11T08:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: %let macro date as date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732835#M228362</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=p1d9ypna2tpt16n1xam57kuffcpt.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;%SYSEVALF macro function&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_SAS=%sysevalf('25AUG2020'd);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Apr 2021 09:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732835#M228362</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-04-11T09:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: %let macro date as date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732837#M228363</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;But I prefer to see the real numeric value of the sas date&lt;/EM&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Your log will be more legible with a human-friendly value such as '12AUG2020'd&amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 09:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732837#M228363</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-04-11T09:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: %let macro date as date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732838#M228364</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I know that I can write&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let start_SAS="25AUG2020"d;&lt;/LI-CODE&gt;
&lt;P&gt;But I prefer to see the real numeric value of the sas date .&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Ideally, you'd use&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let start_dte=25AUG2020;

... where DATE &amp;gt; "&amp;amp;start_dte"d;&lt;/LI-CODE&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 09:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732838#M228364</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-04-11T09:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: %let macro date as date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732842#M228367</link>
      <description>Or inpun() function.&lt;BR /&gt;&lt;BR /&gt;%let start_SAS=%sysfunc(inputn(25AUG2020,date9.));&lt;BR /&gt;&lt;BR /&gt;%put &amp;amp;start_sas ;</description>
      <pubDate>Sun, 11 Apr 2021 10:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732842#M228367</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-11T10:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: %let macro date as date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732877#M228376</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I know that I can write&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let start_SAS="25AUG2020"d;&lt;/LI-CODE&gt;
&lt;P&gt;But I prefer to see the real numeric value of the sas date .&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;has shown you how to get the numeric value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, there is almost no reason to generate the numeric value, which of course is uninterpretable to human eyes.&lt;/P&gt;
&lt;P&gt;Lets say you have&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; %let mydate=25aug2020;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;(note no quotes or other attributes of a date-literal).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you have a human-readable date which can always be used as a date literal by using double quotes, as in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mysubset:
   set mymaster;
   where date&amp;gt;="&amp;amp;mydate"d;
   ...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The point here is that when you surround a macrovar with double quotes SAS will not mask interpretation of the macrovar,&amp;nbsp; i.e. the where statement becomes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   where date&amp;gt;="25aug2020"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you used the single quotes,&amp;nbsp; (i.e.&amp;nbsp; where date&amp;gt;='&amp;amp;mydate'd; ), there would be no resolution of the MYDATE macrovar.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Single quotes prevent macrovar resolution, double quotes don't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 16:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732877#M228376</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-04-11T16:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: %let macro date as date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732897#M228381</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_SAS=%sysfunc(inputn(25AUG2020,date9.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Apr 2021 18:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-macro-date-as-date-value/m-p/732897#M228381</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-11T18:41:33Z</dc:date>
    </item>
  </channel>
</rss>

