<?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: trying to extract a year value from today() using sysfunc in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347852#M63663</link>
    <description>&lt;P&gt;Every datastep function needs a separate %sysfunc.&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let yearnow = %sysfunc(year(%sysfunc(today())));
%put &amp;amp;yearnow;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let datenow = %sysfunc(putn(%sysfunc(today()),yymmdd10.));
%put &amp;amp;datenow;&lt;/PRE&gt;
&lt;P&gt;Or move to a data step as much data manipulation in macro language becomes very ugly and sometimes fragile.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find that the need to have something like %unquote(%str is an indication that I may want to rethink things.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2017 17:43:49 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-04-06T17:43:49Z</dc:date>
    <item>
      <title>trying to extract a year value from today() using sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347834#M63657</link>
      <description>&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;I have a line like this&lt;/P&gt;
&lt;PRE&gt;%LET YEARNOW= %unquote(%str(%'%sysfunc(year(today()), yyyy.)%'));&lt;/PRE&gt;
&lt;P&gt;That throws an error like&lt;/P&gt;
&lt;PRE&gt;ERROR: Required operator not found in expression: today()
ERROR: Argument 1 to function YEAR referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.
ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is terminated.

&lt;/PRE&gt;
&lt;P&gt;What I am trying to do it get the year from a function so I copied this working one&lt;/P&gt;
&lt;PRE&gt;%LET DATENOW= %unquote(%str(%'%sysfunc(today(), yymmdd10.)%'));&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;And tried to Dr it up&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 16:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347834#M63657</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2017-04-06T16:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: trying to extract a year value from today() using sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347838#M63659</link>
      <description>&lt;P&gt;You have two functions, Year() and today(). Each requires its own %SYSFUNC.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let year = %sysfunc(today(), year4.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let year = %sysfunc(year(%sysfunc(today()));&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347838#M63659</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-06T17:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: trying to extract a year value from today() using sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347839#M63660</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let yearnow = %sysfunc(year(%sysfunc(today())));
%put &amp;amp;yearNow;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:08:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347839#M63660</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-06T17:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: trying to extract a year value from today() using sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347847#M63661</link>
      <description>&lt;P&gt;I think you're overcomplicating this a bit.&amp;nbsp; Try it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%LET YEARNOW= %unquote(%str&lt;FONT color="#339966"&gt;(&lt;/FONT&gt;%'%sysfunc&lt;FONT color="#993366"&gt;(&lt;/FONT&gt;today(), year4&lt;FONT color="#993366"&gt;)&lt;/FONT&gt;%'&lt;FONT color="#339966"&gt;)&lt;/FONT&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%SYSFUNC lets you control the format of the value it returns.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347847#M63661</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-06T17:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: trying to extract a year value from today() using sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347852#M63663</link>
      <description>&lt;P&gt;Every datastep function needs a separate %sysfunc.&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let yearnow = %sysfunc(year(%sysfunc(today())));
%put &amp;amp;yearnow;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let datenow = %sysfunc(putn(%sysfunc(today()),yymmdd10.));
%put &amp;amp;datenow;&lt;/PRE&gt;
&lt;P&gt;Or move to a data step as much data manipulation in macro language becomes very ugly and sometimes fragile.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find that the need to have something like %unquote(%str is an indication that I may want to rethink things.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347852#M63663</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-06T17:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: trying to extract a year value from today() using sysfunc</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347856#M63664</link>
      <description>&lt;P&gt;ballardw,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a question of what you want as the final result.&amp;nbsp; You will get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2017&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The added complications that I included will get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'2017'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want quotes around the final value, you need to jump through the extra hoops.&amp;nbsp; But if you don't want the quotes, it becomes even simpler:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let yearnow = %sysfunc(today(), year4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/trying-to-extract-a-year-value-from-today-using-sysfunc/m-p/347856#M63664</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-06T17:48:28Z</dc:date>
    </item>
  </channel>
</rss>

