<?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: First day of year problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158477#M30965</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just because there's more than one way &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let date_range_min = %sysfunc(intnx(year, %sysfunc(date()), 0, b), date9.);&lt;/P&gt;&lt;P&gt;%put &amp;amp;date_range_min.;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Jun 2014 16:34:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-06-27T16:34:03Z</dc:date>
    <item>
      <title>First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158470#M30958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am really struggling to get the first day of year in date9. format into a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please tell me what i am doing wrong here and maybe what would be best.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my code&lt;/P&gt;&lt;P&gt;%let date_range_min = %sysfunc(mdy(1,1,year(date())));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Log error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: Required operator not found in expression: year(date()) &lt;BR /&gt;ERROR: Argument 3 to function MDY 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.&amp;nbsp; Execution of %SYSCALL statement or %SYSFUNC &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or %QSYSFUNC function reference is terminated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Damon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 14:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158470#M30958</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2014-06-27T14:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158471#M30959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eerrm, the first day of the year is 01, why do you need to do any of that.&amp;nbsp; If you want to substr from a date then do:&lt;/P&gt;&lt;P&gt;substr(put(date(),date9.),1,2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and you can put a % before the substr for macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mdy is to create dates not extract from them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 14:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158471#M30959</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-06-27T14:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158472#M30960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let date_range_min=%sysfunc(mdy(1,1,2014),date9.);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 15:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158472#M30960</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-27T15:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158473#M30961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Obviously you will have better ways to do it, but that is OT. For the one you have, You will need %sysfunc for every SAS functions that you used in the macro expressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %let date_range_min = %sysfunc(mdy(1,1,%sysfunc(year(%sysfunc(date())))));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 15:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158473#M30961</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-06-27T15:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158474#M30962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let me clarify what i am trying to do.&amp;nbsp; I need to get the first day of the the current year into a variable in the date9. format.&amp;nbsp; The code from Hai_kuo works to get the date value into the variable but not in a date9. format.&amp;nbsp; I am very new to SAS so if there is a more efficient way to get their I would love to learn it.&amp;nbsp;&amp;nbsp; There is so much that i don't know about this software still.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Needed&lt;/P&gt;&lt;P&gt;&amp;amp;date_range_min=01JAN2014&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all for the quick responses&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 15:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158474#M30962</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2014-06-27T15:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158475#M30963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just add date9. in the syntax to get the desired result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let date_range_min = %sysfunc(mdy(1,1,%sysfunc(year(%sysfunc(date())))),date9.);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 16:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158475#M30963</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-27T16:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158476#M30964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;%let begin_day=%sysfunc(putn(%sysfunc(intnx(year, %sysfunc(today()),0, b)),date9.));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 16:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158476#M30964</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2014-06-27T16:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158477#M30965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just because there's more than one way &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let date_range_min = %sysfunc(intnx(year, %sysfunc(date()), 0, b), date9.);&lt;/P&gt;&lt;P&gt;%put &amp;amp;date_range_min.;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 16:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158477#M30965</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-27T16:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158478#M30966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would use the following to extract the first day of current year: (to &lt;A __default_attr="815716" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;, putn() is abundant here):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let date_range_min = %sysfunc(intnx(year,"&amp;amp;sysdate9"d,0, b), date9.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doing so, you only need to call a SAS function once, and you get to use an existing macro variable that has the system initiating date (be aware of that though). or something I would cal it cheating:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let date_range_min =01JAN%sysfunc(year("&amp;amp;sysdate"d));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck,&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 16:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158478#M30966</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-06-27T16:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: First day of year problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158479#M30967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is beautifully simple.&amp;nbsp; I love efficient code.&amp;nbsp; Thank you everyone for helping me here.&amp;nbsp;&amp;nbsp; I did not realize format was an option of the sysfunc command.&amp;nbsp; I love it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 17:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-day-of-year-problem/m-p/158479#M30967</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2014-06-27T17:34:32Z</dc:date>
    </item>
  </channel>
</rss>

