<?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 cyclically use past 12-month data only in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880075#M347713</link>
    <description>&lt;P&gt;Thank you so much! But the same error messages show up again:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MPRINT(REPORTS): data report202001;&lt;BR /&gt;MPRINT(REPORTS): set clmfile;&lt;BR /&gt;SYMBOLGEN: Macro variable REPORT_DATE resolves to 21915&lt;BR /&gt;388: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;BR /&gt;202: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;BR /&gt;SYMBOLGEN: Macro variable REPORT_DATE resolves to 21915&lt;BR /&gt;MPRINT(REPORTS): if clm_beg_dt between 21915 and ( intnx('month',21915,12)-1);&lt;BR /&gt;MPRINT(REPORTS): run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2023 20:02:10 GMT</pubDate>
    <dc:creator>lichee</dc:creator>
    <dc:date>2023-06-11T20:02:10Z</dc:date>
    <item>
      <title>How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879869#M347591</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I currently have 36-month data, January 2020-December 2022, and want to generate monthly report for 24 months (January 2021-December 2022) using 12-month lookback. For example, to generate the report for&amp;nbsp;January 2021, the data of&amp;nbsp;January 2020-January 2021 should be used, and for the report of February 2021, the data of&amp;nbsp;&amp;nbsp;February 2020-February 2021 can be used.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could anyone guide me how to cyclically keep only 12-month data for the purpose? The example data is as below. The timeframe can be based on&amp;nbsp;service_beg_dt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data clmfile;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID clm_beg_dt :mmddyy10. clm_end_dt :mmddyy10. diag_cd $;&lt;BR /&gt;format clm_beg_dt clm_end_dt mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,1/1/2020,1/1/2020,F02.81&lt;BR /&gt;1,6/1/2020,6/7/2020,F03.90&lt;BR /&gt;1,1/3/2021,1/3/2021,F03.91&lt;BR /&gt;2,2/1/2020,2/5/2020,F04&lt;BR /&gt;2,2/6/2020,2/6/2020,F10.27&lt;BR /&gt;2,2/4/2021,2/6/2021,F10.96&lt;BR /&gt;2,7/2/2022,7/2/2022,F10.97&lt;BR /&gt;3,5/26/2021,5/26/2021,G10&lt;BR /&gt;3,5/27/2021,5/27/2021,G12.21&lt;BR /&gt;3,9/30/2022,10/5/2022,G20&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;Lichee&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 14:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879869#M347591</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-09T14:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879871#M347592</link>
      <description>&lt;P&gt;What goes into the report? You talk about 12 month data, but then you give 13 month intervals (&lt;SPAN&gt;February 2020-February 2021).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Depending on what goes into the report, you may be able to use &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm#n0tcklc8ysnmltn14k6l4el98wbc" target="_self"&gt;multilabel formats&lt;/A&gt; here. As these only work with a few SAS PROCs, other types of reports (such as PROC REPORT) may require either a macro, or a technique similar to "rolling regressions" such as described &lt;A href="https://pages.stern.nyu.edu/~adesouza/sasfinphd/index/node25.html" target="_self"&gt;here&lt;/A&gt; or &lt;A href="https://www.lexjansen.com/nesug/nesug12/fi/fi08.pdf" target="_self"&gt;here&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 14:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879871#M347592</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-09T14:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879873#M347593</link>
      <description>&lt;P&gt;Here is one approach using macro to generate individual rolling 12 reports for a year:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro reports(year);
%do month=1 %to 12;
	%let report_date=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year,mmddyy10.));
	title "Report for %qsysfunc(putn(&amp;amp;report_date,monyy.))"; 
	proc print data=clmfile(Where=(clm_beg_dt between &amp;amp;report_date and (intnx('month',&amp;amp;report_date,12)-1)));
	run;
	title;
%end;
%mend;

options mprint;
%reports(2020)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879873#M347593</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-06-09T15:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879876#M347594</link>
      <description>Please show your desired output if this is your data. Because you're not just straight summing I assume, is it a count of the diag_cd across those time periods? Unique persons? &lt;BR /&gt;&lt;BR /&gt;Depending on the metric, the approach may differ.</description>
      <pubDate>Fri, 09 Jun 2023 15:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879876#M347594</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-06-09T15:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879896#M347598</link>
      <description>&lt;P&gt;I hope it makes sense. Thank you all!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I shall add a few more records in the dummy data. The desired reports are reportYYYYMM. In the reports I wanted to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) list out person_ids with eligible diagnosis code F03.90, F03.91 in the past 12 months,&lt;/P&gt;
&lt;P&gt;2) count number of times a person had the eligible diagnoses in the past 12 months, and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) include the first date when a person had the eligible diagnosis code in the past 12 months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So person_id=1 was reported in the report of January 2021 (report202101), and two individuals (person_ids 1&amp;nbsp; and 4) were reported with eligible diagnosis code in May 2021(report202105) . For the report of June 2021(report202106), person_id=1 is only found to have the eligible diagnosis once in the past 12 months, so the report of the month changes from the previous month. So is the report of January 2022 (report202201). The tricky part is that each monthly report should equally use past 12-month data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data clmfile;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID clm_beg_dt :mmddyy10. clm_end_dt :mmddyy10. diag_cd $;&lt;BR /&gt;format clm_beg_dt clm_end_dt mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,1/1/2020,1/1/2020,F02.81&lt;BR /&gt;1,6/1/2020,6/7/2020,F03.90&lt;BR /&gt;1,1/3/2021,1/3/2021,F03.91&lt;BR /&gt;2,2/1/2020,2/5/2020,F04&lt;BR /&gt;2,2/6/2020,2/6/2020,F10.27&lt;BR /&gt;2,2/4/2021,2/6/2021,F10.96&lt;BR /&gt;2,7/2/2022,7/2/2022,F10.97&lt;BR /&gt;3,5/26/2021,5/26/2021,G10&lt;BR /&gt;3,5/27/2021,5/27/2021,G12.21&lt;BR /&gt;3,9/30/2022,10/5/2022,G20&lt;BR /&gt;4,5/26/2021,5/26/2021,F03.90&lt;BR /&gt;4,5/27/2021,5/27/2021,F03.91&lt;BR /&gt;4,9/30/2022,10/5/2022,F04&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data report202101;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID dx_cnt first_eligible_dx_date :mmddyy10.;&lt;BR /&gt;format first_eligible_dx_date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,2,6/1/2020&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data report202102;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID dx_cnt first_eligible_dx_date :mmddyy10.;&lt;BR /&gt;format first_eligible_dx_date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,2,6/1/2020&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data report202105;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID dx_cnt first_eligible_dx_date :mmddyy10.;&lt;BR /&gt;format first_eligible_dx_date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,2,6/1/2020&lt;BR /&gt;4,2,5/26/2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data report202106;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID dx_cnt first_eligible_dx_date :mmddyy10.;&lt;BR /&gt;format first_eligible_dx_date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,1,1/3/2021&lt;BR /&gt;4,2,5/26/2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data report202107;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID dx_cnt first_eligible_dx_date :mmddyy10.;&lt;BR /&gt;format first_eligible_dx_date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,1,1/3/2021&lt;BR /&gt;4,2,5/26/2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data report202201;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID dx_cnt first_eligible_dx_date :mmddyy10.;&lt;BR /&gt;format first_eligible_dx_date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;4,2,5/26/2021&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/879896#M347598</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-09T16:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880050#M347700</link>
      <description>&lt;P&gt;Thanks Jedi! I tested out the data with your code, and it works well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you guide me to generate reports as data files instead of printing out data? Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 13:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880050#M347700</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-11T13:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880052#M347702</link>
      <description>&lt;P&gt;Instead of PROC PRINT, you create a DATA step that does what you want, with the same WHERE option as used in PROC PRINT.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 14:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880052#M347702</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-11T14:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880053#M347703</link>
      <description>&lt;P&gt;Below is what I tried, but it's not working. Sorry that I'm still learning macro with loops. Thank you!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro reports(year);&lt;BR /&gt;%do month=1 %to 12;&lt;/P&gt;
&lt;P&gt;%let report_date=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year,mmddyy10.));&lt;BR /&gt;%let report_date_yyyymm=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year,yymmn6.));&lt;BR /&gt;data report&amp;amp;report_date_yyyymm.;&lt;BR /&gt;set clmfile;&lt;BR /&gt;if clm_beg_dt between &amp;amp;report_date and (intnx('month',&amp;amp;report_date,12)-1);&lt;BR /&gt;run;&lt;BR /&gt;title;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 14:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880053#M347703</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-11T14:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880062#M347706</link>
      <description>&lt;P&gt;It seems as if you have defined the macro but you never execute it. To execute the macro, add this line underneath the macro and then run it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%reports(2020)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's not the problem, or if it still doesn't work:&lt;/P&gt;
&lt;P&gt;To help debug macros, turn on the MPRINT option before you run your macro. You do this by running this command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, run your macro and show us the ENTIRE log down to the first ERROR and let's say 10 lines after the first error (do NOT show us just the errors)&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 16:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880062#M347706</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-11T16:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880066#M347709</link>
      <description>&lt;P&gt;So I ran the code below:&lt;/P&gt;
&lt;P&gt;%macro reports(year);&lt;BR /&gt;%do month=1 %to 12;&lt;BR /&gt;%let report_date=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year,mmddyy10.));&lt;BR /&gt;%let report_date_yyyymm=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year,yymmn6.));&lt;BR /&gt;data report&amp;amp;report_date_yyyymm.;&lt;BR /&gt;set clmfile;&lt;BR /&gt;if clm_beg_dt between &amp;amp;report_date and (intnx('month',&amp;amp;report_date,12)-1);&lt;BR /&gt;run;&lt;BR /&gt;title;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;options mprint;&lt;BR /&gt;%reports(2020)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error messages are as below:&lt;/P&gt;
&lt;P&gt;MPRINT(REPORTS): data report.;&lt;BR /&gt;MPRINT(REPORTS): set clmfile;&lt;BR /&gt;SYMBOLGEN: Macro variable REPORT_DATE resolves to 21915&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_.&lt;/P&gt;
&lt;P&gt;ERROR 201-322: The option is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;388: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;BR /&gt;202: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;BR /&gt;3 The SAS System 11:05 Friday, June 2, 2023&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable REPORT_DATE resolves to 21915&lt;BR /&gt;MPRINT(REPORTS): if clm_beg_dt between 21915 and ( intnx('month',21915,12)-1);&lt;BR /&gt;MPRINT(REPORTS): run;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 17:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880066#M347709</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-11T17:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880070#M347712</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro reports(year);
%do month=1 %to 12;
%let report_date=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year,mmddyy10.));
/* Next line was changed */
%let report_date_yyyymm=%sysfunc(putn(&amp;amp;report_date,yymmn6.));
data report&amp;amp;report_date_yyyymm;
set clmfile;
if clm_beg_dt between &amp;amp;report_date and (intnx('month',&amp;amp;report_date,12)-1);
run;
title;
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Jun 2023 19:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880070#M347712</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-11T19:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880075#M347713</link>
      <description>&lt;P&gt;Thank you so much! But the same error messages show up again:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MPRINT(REPORTS): data report202001;&lt;BR /&gt;MPRINT(REPORTS): set clmfile;&lt;BR /&gt;SYMBOLGEN: Macro variable REPORT_DATE resolves to 21915&lt;BR /&gt;388: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;BR /&gt;202: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;BR /&gt;SYMBOLGEN: Macro variable REPORT_DATE resolves to 21915&lt;BR /&gt;MPRINT(REPORTS): if clm_beg_dt between 21915 and ( intnx('month',21915,12)-1);&lt;BR /&gt;MPRINT(REPORTS): run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 20:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880075#M347713</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-11T20:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880077#M347715</link>
      <description>&lt;P&gt;I am not getting any errors. Please re-start SAS and see if the code works.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 20:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880077#M347715</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-11T20:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880081#M347717</link>
      <description>&lt;P&gt;I restarted SAS and used the code below, but still got error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;P&gt;data clmfile;&lt;BR /&gt;infile datalines truncover dsd;&lt;BR /&gt;input Person_ID clm_beg_dt :mmddyy10. clm_end_dt :mmddyy10. diag_cd $;&lt;BR /&gt;format clm_beg_dt clm_end_dt mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1,1/1/2020,1/1/2020,F02.81&lt;BR /&gt;1,6/1/2020,6/7/2020,F03.90&lt;BR /&gt;1,1/3/2021,1/3/2021,F03.91&lt;BR /&gt;2,2/1/2020,2/5/2020,F04&lt;BR /&gt;2,2/6/2020,2/6/2020,F10.27&lt;BR /&gt;2,2/4/2021,2/6/2021,F10.96&lt;BR /&gt;2,7/2/2022,7/2/2022,F10.97&lt;BR /&gt;3,5/26/2021,5/26/2021,G10&lt;BR /&gt;3,5/27/2021,5/27/2021,G12.21&lt;BR /&gt;3,9/30/2022,10/5/2022,G20&lt;BR /&gt;4,5/26/2021,5/26/2021,F03.90&lt;BR /&gt;4,5/27/2021,5/27/2021,F03.91&lt;BR /&gt;4,9/30/2022,10/5/2022,F04&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;options mprint;&lt;/P&gt;
&lt;P&gt;%macro reports(year);&lt;BR /&gt;%do month=1 %to 12;&lt;BR /&gt;%let report_date=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year.,mmddyy10.));&lt;BR /&gt;/* Next line was changed */&lt;BR /&gt;%let report_date_yyyymm=%sysfunc(putn(&amp;amp;report_date.,yymmn6.));&lt;BR /&gt;data report&amp;amp;report_date_yyyymm.;&lt;BR /&gt;set clmfile;&lt;BR /&gt;if clm_beg_dt between &amp;amp;report_date and (intnx('month',&amp;amp;report_date,12)-1);&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%reports(2020)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Log error message:&lt;/P&gt;
&lt;P&gt;MPRINT(REPORTS): data report202001;&lt;BR /&gt;MPRINT(REPORTS): set clmfile;&lt;BR /&gt;388: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;BR /&gt;202: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;BR /&gt;MPRINT(REPORTS): if clm_beg_dt between 21915 and ( intnx('month',21915,12)-1);&lt;BR /&gt;MPRINT(REPORTS): run;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: MVA_DSIO.OPEN_CLOSE| _DISARM| STOP| _DISARM| 2023-06-11T16:34:22,563-04:00| _DISARM| WorkspaceServer| _DISARM| | &lt;BR /&gt;_DISARM| | _DISARM| | _DISARM| 19492864| _DISARM| 10| _DISARM| 11| _DISARM| 3584| _DISARM| 14056203| _DISARM| | _DISARM| | &lt;BR /&gt;_DISARM| | _DISARM| | _DISARM| | _DISARM| | _ENDDISARM &lt;BR /&gt;WARNING: The data set WORK.REPORT202001 may be incomplete. When this step was stopped there were 0 observations and 4 variables.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 20:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880081#M347717</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-11T20:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880091#M347722</link>
      <description>&lt;P&gt;BETWEEN does not work in the IF statement here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if &amp;amp;report_date &amp;lt;= clm_beg_dt &amp;lt;= (intnx('month',&amp;amp;report_date,12)-1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Jun 2023 21:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880091#M347722</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-11T21:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880121#M347747</link>
      <description>&lt;P&gt;This works well!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, the timeframe if &amp;amp;report_date. &amp;lt;= clm_beg_dt &amp;lt;= (intnx('month',&amp;amp;report_date.,12)-1) is actually looking ahead, instead of looking back. I'm trying to use 11-month lookback as below:&lt;/P&gt;
&lt;P&gt;%macro reports(year);&lt;BR /&gt;%do month=1 %to 12;&lt;BR /&gt;%let report_date=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year,mmddyy10.));&lt;BR /&gt;%let report_date_yyyymm=%sysfunc(putn(&amp;amp;report_date.,yymmn6.));&lt;BR /&gt;%let beg_dt=%sysfunc(putn(intnx('month',&amp;amp;report_date.,-11),mmddyy10.));&lt;BR /&gt;%let end_dt=%sysfunc(putn(intnx('month',&amp;amp;report_date.,0,'E'),mmddyy10.));&lt;/P&gt;
&lt;P&gt;data report&amp;amp;report_date_yyyymm.;&lt;BR /&gt;set clmfile;&lt;BR /&gt;if &amp;amp;beg_dt.&amp;lt;= clm_beg_dt &amp;lt;=&amp;amp;end_dt.;&lt;BR /&gt;run;&lt;BR /&gt;title;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%reports(2021)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;There&amp;nbsp; are error messages as below:&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable REPORT_DATE resolves to 22281&lt;BR /&gt;ERROR: Argument 1 to function PUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC &lt;BR /&gt;or %QSYSFUNC function reference is terminated.&lt;BR /&gt;MLOGIC(REPORTS): %LET (variable name is END_DT)&lt;BR /&gt;SYMBOLGEN: Macro variable REPORT_DATE resolves to 22281&lt;BR /&gt;ERROR: Required operator not found in expression: intnx('month',22281,0,'E') &lt;BR /&gt;ERROR: Argument 1 to function PUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC &lt;BR /&gt;or %QSYSFUNC function reference is terminated.&lt;BR /&gt;SYMBOLGEN: Macro variable REPORT_DATE_YYYYMM resolves to 202101&lt;BR /&gt;MPRINT(REPORTS): data report202101;&lt;BR /&gt;MPRINT(REPORTS): set clmfile;&lt;BR /&gt;SYMBOLGEN: Macro variable BEG_DT resolves to &lt;BR /&gt;22: LINE and COLUMN cannot be determined.&lt;BR /&gt;NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, &lt;BR /&gt;a missing value, INPUT, PUT. &lt;BR /&gt;SYMBOLGEN: Macro variable END_DT resolves to &lt;BR /&gt;22: LINE and COLUMN cannot be determined.&lt;BR /&gt;3 The SAS System 23:12 Saturday, June 10, 2023&lt;/P&gt;
&lt;P&gt;NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, &lt;BR /&gt;a missing value, bitstring, INPUT, PUT. &lt;BR /&gt;MPRINT(REPORTS): if &amp;lt;= clm_beg_dt &amp;lt;= ;&lt;BR /&gt;MPRINT(REPORTS): run;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 02:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880121#M347747</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-12T02:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880122#M347748</link>
      <description>&lt;P&gt;11-month lookback is specifically to have the past 11-month data and data of the current month. For example, when the report month is January 2021, I wanted to keep the data of February 2020 to&amp;nbsp;January 2021, for February 2021, to keep data of March 2020 to&amp;nbsp;February 2021,. etc..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank a lot!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 03:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880122#M347748</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-12T03:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880183#M347780</link>
      <description>&lt;P&gt;Inside %SYSFUNC you do not use quotes around text strings. There is no need for PUTN in &amp;amp;BEG_DT and &amp;amp;END_DT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let beg_dt=%sysfunc(intnx(month,&amp;amp;report_date.,-11));
%let end_dt=%sysfunc(intnx(month,&amp;amp;report_date.,0,E));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2023 11:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880183#M347780</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-12T11:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to cyclically use past 12-month data only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880293#M347811</link>
      <description>&lt;P&gt;I combined all your suggestions and answers. The code below provides me the desired output for my initial ask. Thank you very much to you all!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro reports(year);&lt;BR /&gt;%do month=1 %to 12;&lt;BR /&gt;%let report_date=%sysfunc(inputn(&amp;amp;month/01/&amp;amp;year,mmddyy10.));&lt;BR /&gt;%let report_date_yyyymm=%sysfunc(putn(&amp;amp;report_date.,yymmn6.));&lt;BR /&gt;%let beg_dt=%sysfunc(intnx(month,&amp;amp;report_date.,-11));&lt;BR /&gt;%let end_dt=%sysfunc(intnx(month,&amp;amp;report_date.,0,E));&lt;BR /&gt;data report&amp;amp;report_date_yyyymm.;&lt;BR /&gt;set clmfile;&lt;BR /&gt;if &amp;amp;beg_dt.&amp;lt;= clm_beg_dt &amp;lt;=&amp;amp;end_dt.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%reports(2021)&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 20:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cyclically-use-past-12-month-data-only/m-p/880293#M347811</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2023-06-12T20:38:52Z</dc:date>
    </item>
  </channel>
</rss>

