<?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: select data load date by previous date in Advanced Programming</title>
    <link>https://communities.sas.com/t5/Advanced-Programming/select-data-load-date-by-previous-date/m-p/839134#M207</link>
    <description>&lt;P&gt;Assuming your real code was already of better quality than what you've posted the reason is likely that you've enclosed the macro variable in single quotes. You need double quotes for the macro variable to resolve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below working sample code with all the syntax you've posted fixed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let prev_day = %sysfunc(intnx(day, %sysfunc(today()),-1), date9.);
%put &amp;amp;=prev_day;

data have;
  format date_load_dttm datetime21.;
  do i=-3 to 3;
    date_load_dttm=intnx('dtday',datetime(),i); 
    output;
  end;
run;

data want;
  set have;
  if datepart(date_load_dttm) &amp;lt; "&amp;amp;prev_day"d;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 18 Oct 2022 07:30:12 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2022-10-18T07:30:12Z</dc:date>
    <item>
      <title>select data load date by previous date</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/select-data-load-date-by-previous-date/m-p/839129#M206</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have defined an macro prev_day&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let prev_day = sysfunc(intnx(day, %sysfunc(today(),-1), date9.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have a column name data_loade_dt, which is datetime&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish to select the data loaded before previous date,&lt;/P&gt;
&lt;P&gt;so in my where condition I write:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where datepart(date_load_dt) &amp;lt; '&amp;amp; prev_day'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which result a wrong format SAS cannot compare the pre_day in my selection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise.&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 07:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/select-data-load-date-by-previous-date/m-p/839129#M206</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2022-10-18T07:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: select data load date by previous date</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/select-data-load-date-by-previous-date/m-p/839134#M207</link>
      <description>&lt;P&gt;Assuming your real code was already of better quality than what you've posted the reason is likely that you've enclosed the macro variable in single quotes. You need double quotes for the macro variable to resolve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below working sample code with all the syntax you've posted fixed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let prev_day = %sysfunc(intnx(day, %sysfunc(today()),-1), date9.);
%put &amp;amp;=prev_day;

data have;
  format date_load_dttm datetime21.;
  do i=-3 to 3;
    date_load_dttm=intnx('dtday',datetime(),i); 
    output;
  end;
run;

data want;
  set have;
  if datepart(date_load_dttm) &amp;lt; "&amp;amp;prev_day"d;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Oct 2022 07:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/select-data-load-date-by-previous-date/m-p/839134#M207</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-18T07:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: select data load date by previous date</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/select-data-load-date-by-previous-date/m-p/839135#M208</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;, thank you! It worked!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 07:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/select-data-load-date-by-previous-date/m-p/839135#M208</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2022-10-18T07:58:40Z</dc:date>
    </item>
  </channel>
</rss>

