<?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: How to use macro variables to retrieve data of a specific time window in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931147#M366336</link>
    <description>&lt;P&gt;First off look at this code carefully:&lt;/P&gt;
&lt;PRE&gt;493 %if &amp;amp;season. = spring %then %do;
494
495 %let start = "01APR%eval(&amp;amp;CurrentYr. - 1)&lt;FONT color="#008000"&gt;&lt;STRONG&gt;:00:00:00"&lt;FONT size="5"&gt;dt&lt;/FONT&gt;;&lt;/STRONG&gt;&lt;/FONT&gt;
496 %let end = "30SEP%eval(&amp;amp;CurrentYr. - 1):23:59:59"dt;
497
498 %end;
499
500 %if &amp;amp;season. = fall %then %do;
501
502 %let start = "01OCT%eval(&amp;amp;CurrentYr. - 1)&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;:00:00:00"&lt;FONT size="5"&gt;d&lt;/FONT&gt;;&lt;/STRONG&gt;&lt;/FONT&gt;
503 %let end = "31MAR(&amp;amp;CurrentYr.):23:59:59"dt;&lt;/PRE&gt;
&lt;P&gt;One of these things is not like the others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, if the value resolves to a DATETIME value then almost any of the DATE format formats, such as YYMMDD will do one of two things, return the wrong value OR FAIL because datetimes have seconds as units and dates have days as units. So most datetime values overflow the allowed range of the date formats (which are currently only good to the year 9999)&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;PRE&gt;data junk;
  datetime = '01JAN1960:12:00:00'dt;
  put datetime= yymmdd10.;
run;&lt;/PRE&gt;
&lt;P&gt;Check the log to see what is displayed.&lt;/P&gt;
&lt;P&gt;So you don't want that format involved at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jun 2024 14:46:46 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-06-06T14:46:46Z</dc:date>
    <item>
      <title>How to use macros to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/930926#M366261</link>
      <description>&lt;P&gt;I have below Macros&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;*create macro variables for start and end dates for this cycle;&lt;/DIV&gt;&lt;DIV&gt;%if &amp;amp;season. = spring %then %do;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let start = "01APR%eval(&amp;amp;CurrentYr. - 1)"d;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let end = "30SEP%eval(&amp;amp;CurrentYr. - 1)"d;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;%end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;%if &amp;amp;season. = fall %then %do;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let start = "01OCT%eval(&amp;amp;CurrentYr. - 1)"d;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let end = "31MAR&amp;amp;CurrentYr."d;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;%end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*Macro variables definitions - to use this macro, specify things in date9 - human readable&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;To use the same values as inputs to the various %get macros, convert them - negates having to add input macro parameters ;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*start;&lt;/DIV&gt;&lt;DIV&gt;%let xstart = %sysfunc(putn(&amp;amp;start.,yymmddn8.));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*end;&lt;/DIV&gt;&lt;DIV&gt;%let xend = %sysfunc(putn(&amp;amp;end,yymmddn8.));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*cycle;&lt;/DIV&gt;&lt;DIV&gt;%let cyc = %sysfunc(putn(&amp;amp;start.,yymmn.));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*180 days prior to the earliest possible ddate - palliative;&lt;/DIV&gt;&lt;DIV&gt;%let xstart180 = %sysfunc(putn(&amp;amp;start.-180,yymmddn8.));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*put latest rpdb postal year into a macro variable&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sql;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;select max(year)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;into :RPDByr&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from rpdb;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;quit;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;*double check they resolve properly;&lt;/DIV&gt;&lt;DIV&gt;%put &amp;amp;xstart.;&lt;/DIV&gt;&lt;DIV&gt;%put &amp;amp;xend.;&lt;/DIV&gt;&lt;DIV&gt;%put &amp;amp;cyc.;&lt;/DIV&gt;&lt;DIV&gt;%put &amp;amp;xstart180.;&lt;/DIV&gt;&lt;DIV&gt;%put &amp;amp;RPDByr.;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have a dataset called patient ( including one column named "date) and I want to retrieve the observation fall in the %xstart and %xend date, how do I write the code?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very much for your suggestions.&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Jun 2024 14:04:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/930926#M366261</guid>
      <dc:creator>yming954</dc:creator>
      <dc:date>2024-06-05T14:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macros to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/930928#M366263</link>
      <description>&lt;P&gt;Is the "date" variable supposed to contain SAS date values or character strings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If date is SAS date values then it is very likely that your Xstart and Xend will almost never be appropriate.&lt;/P&gt;
&lt;P&gt;If Date is just some random numeric value that happens to hold numbers like 20240516 then possibly:&lt;/P&gt;
&lt;PRE&gt;where &amp;amp;xstart. le date le &amp;amp;xend. &lt;/PRE&gt;
&lt;P&gt;If date holds character strings like "20240516" then&lt;/P&gt;
&lt;PRE&gt;where "&amp;amp;xstart." le date le "&amp;amp;xend." &lt;/PRE&gt;
&lt;P&gt;you don't mention if your "fall in the range" includes the end points or not. My example includes them.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 14:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/930928#M366263</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-05T14:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro variables to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/930930#M366264</link>
      <description>&lt;P&gt;When macro variables are to be used for arithmetic or logical operations, they SHOULD NOT be formatted. &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 28&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let xstart = &amp;amp;start; %put &amp;amp;=xstart; /* Note: no format */
%let xend = &amp;amp;end; %put &amp;amp;=xend; /* Note: no format */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then in SQL or a DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where date between &amp;amp;xstart and &amp;amp;xend&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes variable DATE has actual numeric SAS date values, but you really haven't specified that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you don't have macros here. You have macro variables, these are not the same. Best to call these macro variables.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 15:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/930930#M366264</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-05T15:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macros to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/930994#M366282</link>
      <description>&lt;P&gt;Thank you very much for your advice&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My variable contains date format like ddmmmyyyy (date9.)&lt;/P&gt;&lt;P&gt;Will that work using the first code? Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 17:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/930994#M366282</guid>
      <dc:creator>yming954</dc:creator>
      <dc:date>2024-06-05T17:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macros to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931005#M366283</link>
      <description>&lt;P&gt;May be time to run Proc Contents on your data set and share the variable details. Tell us the actual name of the variable so we can be sure to understand which details are needed to answer that question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466441"&gt;@yming954&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much for your advice&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My variable contains date format like ddmmmyyyy (date9.)&lt;/P&gt;
&lt;P&gt;Will that work using the first code? Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If your variable is actually numeric with a date9 format attached then your &amp;amp;Xstart and &amp;amp;Xend variables are structured incorrectly and you would want to use the &amp;amp;start and &amp;amp;end in comparison as they should resolve to date values (hopefully , there's lots of details we don't have like &amp;amp;Season (which might have issues with case: Fall vs fall in the comparison for example) &amp;amp;Currentyr which I hope is 4 digits (2 digit years of 00 to 10 will fail creating invalid date literals&lt;/P&gt;
&lt;P&gt;example:&lt;/P&gt;
&lt;PRE&gt;%let CurrentYr= 09;
%let start = "01OCT%eval(&amp;amp;CurrentYr. - 1)"d;
%put &amp;amp;start.;&lt;/PRE&gt;
&lt;P&gt;where Start is "01OCT8"d which is not a valid date literal. Year 00 would yield "01OCT-1"d which is also way off.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 18:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931005#M366283</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-05T18:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macros to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931037#M366287</link>
      <description>&lt;P&gt;So you have the following macro statements (there is no macro here since I do not see a %MACRO statement nor a %MEND statement).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;season. = spring %then %do;
  %let start = "01APR%eval(&amp;amp;CurrentYr. - 1)"d;
  %let end = "30SEP%eval(&amp;amp;CurrentYr. - 1)"d;
%end;
%if &amp;amp;season. = fall %then %do;
  %let start = "01OCT%eval(&amp;amp;CurrentYr. - 1)"d;
  %let end = "31MAR&amp;amp;CurrentYr."d;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Might be easier (and safer) to calculate the previous year number only once. So something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let previousyr=%eval(&amp;amp;currentyr-1);
%if %upcase(&amp;amp;season) = SPRING %then %do;
  %let start = "01APR&amp;amp;previousyr"d;
  %let end = "30SEP&amp;amp;previousyr"d;
%end;
%else %if %upcase(&amp;amp;season) = FALLl %then %do;
  %let start = "01OCT&amp;amp;previousyr"d;
  %let end = "31MAR&amp;amp;CurrentYr."d;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now that you have two macro variables with SAS date literals in them you can use them in your code anywhere that SAS would want a date value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set PATIENT;
  where date between &amp;amp;start and &amp;amp;end ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that DATE has numeric data values.&amp;nbsp; What display format is attached to the DATE variable does not matter.&amp;nbsp; It is the range of values that it contains that will impact whether the WHERE statement selects the observation or not.&amp;nbsp; The first day of November in the year 2000 is stored as the number 14,915 and displaying it with different formats does not change that fact.&lt;/P&gt;
&lt;PRE&gt;2490  data test;
2491    date='01NOV2000'd;
2492    put (5*date) (=comma. +1 date9. +1 yymmdd10. +1 mmddyy10. +1 ddmmyy10.);
2493  run;

date=14,915  01NOV2000 2000-11-01 11/01/2000 01/11/2000
&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jun 2024 20:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931037#M366287</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-05T20:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macros to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931045#M366290</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the date format is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yming954_1-1717619056855.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97054i0232E7E69901C937/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yming954_1-1717619056855.png" alt="yming954_1-1717619056855.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what should I do to fix the macros?&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>Wed, 05 Jun 2024 20:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931045#M366290</guid>
      <dc:creator>yming954</dc:creator>
      <dc:date>2024-06-05T20:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro variables to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931051#M366291</link>
      <description>&lt;P&gt;So you are not using macros, you are using macro variables. Macro variables are not macros. ANd you don't have a valid SAS date variable, you have a DATETIME variable, which is different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the macro variables must contain valid DATETIME values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start = "01APR%eval(&amp;amp;CurrentYr. - 1):00:00:00"dt;
%let end = "30SEP%eval(&amp;amp;CurrentYr. - 1):23:59:89"dt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the values contain hours:minutes:seconds and the DDMONYY part. Note the dt at the end indicating these are DATETIME values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now this should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where dischargedate between &amp;amp;start and &amp;amp;end&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jun 2024 21:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931051#M366291</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-05T21:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macros to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931053#M366293</link>
      <description>&lt;P&gt;To compare a variable that is a DATETIME as shown with a DATE value you would want to extract the date portion of the datetime variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;amp;start. le datepart(DischargeDate) le &amp;amp;end. &lt;/PRE&gt;
&lt;P&gt;should work if the &amp;amp;start and &amp;amp;end contain the correct date values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Style choice: many of us do not like having the quotes as part of a macro variable value as when you read the code it may not show up that here &amp;amp;start is a quoted date literal, i.e, something like "01JAN2024"D .&lt;/P&gt;
&lt;P&gt;If using date literals with macro variables I prefer to have the value in the macro variable as 01JAN2024 and then in the comparison code would use&lt;/P&gt;
&lt;PRE&gt;"&amp;amp;start."d le Datepart(DischargeDate) ...&lt;/PRE&gt;
&lt;P&gt;So when I see it I have a better idea what &amp;amp;start should look like. This allow use of the &amp;amp;start in places where I might want text such as&lt;/P&gt;
&lt;PRE&gt;Title "XYZ Report starting &amp;amp;Start.";&lt;/PRE&gt;
&lt;P&gt;Which would resolve to&lt;/P&gt;
&lt;PRE&gt;XYZ Report starting 01JAN2024&lt;/PRE&gt;
&lt;P&gt;where the title was used. (or as part of the name of an output file)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466441"&gt;@yming954&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the date format is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yming954_1-1717619056855.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97054i0232E7E69901C937/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yming954_1-1717619056855.png" alt="yming954_1-1717619056855.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what should I do to fix the macros?&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;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 21:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931053#M366293</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-05T21:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro variables to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931128#M366331</link>
      <description>&lt;P&gt;493 %if &amp;amp;season. = spring %then %do;&lt;BR /&gt;494&lt;BR /&gt;495 %let start = "01APR%eval(&amp;amp;CurrentYr. - 1):00:00:00"dt;&lt;BR /&gt;496 %let end = "30SEP%eval(&amp;amp;CurrentYr. - 1):23:59:59"dt;&lt;BR /&gt;497&lt;BR /&gt;498 %end;&lt;BR /&gt;499&lt;BR /&gt;500 %if &amp;amp;season. = fall %then %do;&lt;BR /&gt;501&lt;BR /&gt;502 %let start = "01OCT%eval(&amp;amp;CurrentYr. - 1):00:00:00"d;&lt;BR /&gt;503 %let end = "31MAR(&amp;amp;CurrentYr.):23:59:59"dt;&lt;BR /&gt;504&lt;BR /&gt;505 %end;&lt;/P&gt;&lt;P&gt;506 *start;&lt;BR /&gt;507 %let xstart = %sysfunc(putn(&amp;amp;start.,yymmddn8.));&lt;BR /&gt;508&lt;BR /&gt;509 *end;&lt;BR /&gt;510 %let xend = %sysfunc(putn(&amp;amp;end,yymmddn8.));&lt;BR /&gt;&lt;FONT face="impact,chicago"&gt;ERROR: Argument 1 to function PUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="impact,chicago"&gt;not a number.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="impact,chicago"&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="impact,chicago"&gt;Execution of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="impact,chicago"&gt;terminated.&lt;/FONT&gt;&lt;BR /&gt;511&lt;BR /&gt;512 *cycle;&lt;BR /&gt;513 %let cyc = %sysfunc(putn(&amp;amp;start.,yymmn.));&lt;BR /&gt;514&lt;BR /&gt;515 *180 days prior to the earliest possible ddate - palliative;&lt;BR /&gt;516 %let xstart180 = %sysfunc(putn(&amp;amp;start.-180,yymmddn8.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; I am getting this errors, how could I fix it? Thank you very much for your guidance&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 13:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931128#M366331</guid>
      <dc:creator>yming954</dc:creator>
      <dc:date>2024-06-06T13:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro variables to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931135#M366333</link>
      <description>&lt;P&gt;You don't need &amp;amp;xstart and &amp;amp;xend any more, get rid of them, just use &amp;amp;start and &amp;amp;end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please remember that macro variables that contain date or datetime values which will be used for arithmetic or logical operations should NOT be formatted.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 13:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931135#M366333</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-06T13:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro variables to retrieve data of a specific time window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931147#M366336</link>
      <description>&lt;P&gt;First off look at this code carefully:&lt;/P&gt;
&lt;PRE&gt;493 %if &amp;amp;season. = spring %then %do;
494
495 %let start = "01APR%eval(&amp;amp;CurrentYr. - 1)&lt;FONT color="#008000"&gt;&lt;STRONG&gt;:00:00:00"&lt;FONT size="5"&gt;dt&lt;/FONT&gt;;&lt;/STRONG&gt;&lt;/FONT&gt;
496 %let end = "30SEP%eval(&amp;amp;CurrentYr. - 1):23:59:59"dt;
497
498 %end;
499
500 %if &amp;amp;season. = fall %then %do;
501
502 %let start = "01OCT%eval(&amp;amp;CurrentYr. - 1)&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;:00:00:00"&lt;FONT size="5"&gt;d&lt;/FONT&gt;;&lt;/STRONG&gt;&lt;/FONT&gt;
503 %let end = "31MAR(&amp;amp;CurrentYr.):23:59:59"dt;&lt;/PRE&gt;
&lt;P&gt;One of these things is not like the others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, if the value resolves to a DATETIME value then almost any of the DATE format formats, such as YYMMDD will do one of two things, return the wrong value OR FAIL because datetimes have seconds as units and dates have days as units. So most datetime values overflow the allowed range of the date formats (which are currently only good to the year 9999)&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;PRE&gt;data junk;
  datetime = '01JAN1960:12:00:00'dt;
  put datetime= yymmdd10.;
run;&lt;/PRE&gt;
&lt;P&gt;Check the log to see what is displayed.&lt;/P&gt;
&lt;P&gt;So you don't want that format involved at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 14:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macros-to-retrieve-data-of-a-specific-time-window/m-p/931147#M366336</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-06T14:46:46Z</dc:date>
    </item>
  </channel>
</rss>

