<?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: Nested SYSEVALF Errors in Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623651#M183640</link>
    <description>And if you're using it often, maybe use PROC FCMP to make it a custom function?</description>
    <pubDate>Mon, 10 Feb 2020 18:22:49 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-02-10T18:22:49Z</dc:date>
    <item>
      <title>Nested SYSEVALF Errors in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623630#M183633</link>
      <description>&lt;P&gt;I have the following macro to calculate the number of days in a year...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro leapyear;
	%global lyear_curr lyear_prev;

	%let sysyear_curr = %sysfunc(year("&amp;amp;sysdate"d));
	%let sysyear_prev = %sysevalf(&amp;amp;sysyear_curr - 1);

	%let days_curr_yr = intck('days',(mdy(1,1,&amp;amp;sysyear_curr)),(mdy(1,1,(&amp;amp;sysyear_curr))),'continuous');
	%let days_prev_yr = intck('days',(mdy(1,1,&amp;amp;sysyear_prev)),(mdy(1,1,(&amp;amp;sysyear_prev))),'continuous');

	%put &amp;amp;=days_curr_yr &amp;amp;=days_prev_yr;
%mend;
%leapyear;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I an getting errors on the sysevalf saying it is too long....probably something simple. Any ideas? I plan to use the days to check for leap year and assign a variable accordingly.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 17:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623630#M183633</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2020-02-10T17:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SYSEVALF Errors in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623632#M183634</link>
      <description>You need to wrap your functions in %SYSFUNC(). Every single function in a %LET needs to be wrapped, including your INTCK() and MDY(). A data step seems significantly easier here IMO using CALL SYMPUTX().</description>
      <pubDate>Mon, 10 Feb 2020 17:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623632#M183634</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-10T17:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SYSEVALF Errors in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623634#M183635</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro leapyear;
	%global lyear_curr lyear_prev;

	%let sysyear_curr = %sysfunc(year("&amp;amp;sysdate"d));
	%let sysyear_prev = %sysevalf(&amp;amp;sysyear_curr - 1);

	%let days_curr_yr = %sysfunc(intck(day,%sysfunc(mdy(1,1,&amp;amp;sysyear_curr)),%sysevalf(%sysfunc(mdy(12,31,&amp;amp;sysyear_curr))+1)));
	%let days_prev_yr = %sysfunc(intck(day,%sysfunc(mdy(1,1,&amp;amp;sysyear_prev)),%sysevalf(%sysfunc(mdy(12,31,&amp;amp;sysyear_prev))+1)));

	%put &amp;amp;=days_curr_yr &amp;amp;=days_prev_yr;
%mend;
%leapyear;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2020 17:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623634#M183635</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-10T17:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SYSEVALF Errors in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623639#M183637</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 17:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623639#M183637</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2020-02-10T17:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SYSEVALF Errors in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623641#M183638</link>
      <description>&lt;P&gt;The number of days in the current year?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %eval(
 %sysfunc(intnx(year,"&amp;amp;sysdate9"d,0,e))
-%sysfunc(intnx(year,"&amp;amp;sysdate9"d,0,b))
+1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2020 17:33:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623641#M183638</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-10T17:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SYSEVALF Errors in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623651#M183640</link>
      <description>And if you're using it often, maybe use PROC FCMP to make it a custom function?</description>
      <pubDate>Mon, 10 Feb 2020 18:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623651#M183640</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-10T18:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SYSEVALF Errors in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623766#M183680</link>
      <description>&lt;P&gt;No errors:&lt;/P&gt;
&lt;PRE&gt;27         %macro leapyear;
28         	%global lyear_curr lyear_prev;
29         
30         	%let sysyear_curr = %sysfunc(year("&amp;amp;sysdate"d));
31         	%let sysyear_prev = %sysevalf(&amp;amp;sysyear_curr - 1);
32         
33         	%let days_curr_yr = intck('days',(mdy(1,1,&amp;amp;sysyear_curr)),(mdy(1,1,(&amp;amp;sysyear_curr))),'continuous');
34         	%let days_prev_yr = intck('days',(mdy(1,1,&amp;amp;sysyear_prev)),(mdy(1,1,(&amp;amp;sysyear_prev))),'continuous');
35         
36         	%put &amp;amp;=days_curr_yr &amp;amp;=days_prev_yr;
37         %mend;
38         %leapyear;
DAYS_CURR_YR=intck('days',(mdy(1,1,2020)),(mdy(1,1,(2020))),'continuous') 
DAYS_PREV_YR=intck('days',(mdy(1,1,2019)),(mdy(1,1,(2019))),'continuous')
&lt;/PRE&gt;
&lt;P&gt;But, as is to be expected, the macro variables do not contain values, but the text you stored in them. Close inspection of the first macro variable shows that it would return a zero when used in a data step.&lt;/P&gt;
&lt;P&gt;You can greatly simplify your macro by making use of the fact that dates are counts of days:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro leapyear;
%global lyear_curr lyear_prev;
%let lyear_curr = %eval(%sysfunc(intnx(year,%sysfunc(today()),1,b))-%sysfunc(intnx(year,%sysfunc(today()),0,b)));
%let lyear_prev = %eval(%sysfunc(intnx(year,%sysfunc(today()),0,b))-%sysfunc(intnx(year,%sysfunc(today()),-1,b)));
%mend;
%leapyear
%put &amp;amp;lyear_curr;
%put &amp;amp;lyear_prev;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Feb 2020 06:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Nested-SYSEVALF-Errors-in-Macro/m-p/623766#M183680</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-11T06:31:15Z</dc:date>
    </item>
  </channel>
</rss>

