<?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: Extracting month and year from %sysdate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/316359#M69112</link>
    <description>Instead of re-activating a zombie topic, start a new one, using appropriate title.</description>
    <pubDate>Fri, 02 Dec 2016 19:21:49 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2016-12-02T19:21:49Z</dc:date>
    <item>
      <title>Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46736#M9646</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to use the current month and year from %sysdate or any other function within a report.&lt;BR /&gt;
Would anyone know how to extract these values and assign them to a variable or macr variable.&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Fri, 08 Apr 2011 12:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46736#M9646</guid>
      <dc:creator>chuckdee4</dc:creator>
      <dc:date>2011-04-08T12:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46737#M9647</link>
      <description>&lt;P&gt;Following program creates both data step variables and macro variables.&lt;BR /&gt; &lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
month = month(input("&amp;amp;sysdate9",date9.));
year = year(input("&amp;amp;sysdate9",date9.));
call symput('month',compress(put(month,best.)));
call symput('year',compress(put(year,best.)));
run;

%put &amp;amp;year;
%put &amp;amp;month;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;And a way to do it without a data step:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let sysmonth= %sysfunc(month("&amp;amp;sysdate"d));
%let sysyear= %sysfunc(year("&amp;amp;sysdate"d));

%put &amp;amp;sysmonth &amp;amp;sysyear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;Remember that SYSDATE has the start date of the SAS session, not the calendar date at the time of execution.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 16 Aug 2017 12:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46737#M9647</guid>
      <dc:creator>NickR</dc:creator>
      <dc:date>2017-08-16T12:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46738#M9648</link>
      <description>Many thanks Nick will apply this and advice on how it goes.</description>
      <pubDate>Fri, 08 Apr 2011 13:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46738#M9648</guid>
      <dc:creator>chuckdee4</dc:creator>
      <dc:date>2011-04-08T13:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46739#M9649</link>
      <description>And a way to do it without a data step:&lt;BR /&gt;
&lt;BR /&gt;
%let sysmonth= %sysfunc(month("&amp;amp;sysdate"d));&lt;BR /&gt;
%let sysyear= %sysfunc(year("&amp;amp;sysdate"d));&lt;BR /&gt;
&lt;BR /&gt;
%put  &amp;amp;sysmonth &amp;amp;sysyear;&lt;BR /&gt;
&lt;BR /&gt;
Remember that SYSDATE has the start date of the SAS session, not the calendar date at the time of execution.</description>
      <pubDate>Fri, 08 Apr 2011 20:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46739#M9649</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-04-08T20:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46740#M9650</link>
      <description>Nick the codes worked just fine, thanks&lt;BR /&gt;
&lt;BR /&gt;
Ballardw, many thanks for your suggestion seems to do the sae job with less code, will implement it in future projects</description>
      <pubDate>Mon, 11 Apr 2011 21:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/46740#M9650</guid>
      <dc:creator>chuckdee4</dc:creator>
      <dc:date>2011-04-11T21:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/288933#M59636</link>
      <description>&lt;P&gt;I' d like to get month as Jun for example. Is it possible?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 13:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/288933#M59636</guid>
      <dc:creator>Vladimir</dc:creator>
      <dc:date>2016-08-02T13:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/304329#M64783</link>
      <description>&lt;P&gt;Hi Nick&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found this very useful, but I recently come across a situation slightly different. The macro returns the below values, but for my code I need it to say "OCT" rather than "10". I have tried formatting but it did not work. Is there a way to amend this code to get it to output the character 3 letter name of the month? Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;macro result:&lt;/P&gt;&lt;P&gt;10&amp;nbsp;2016&lt;/P&gt;&lt;P&gt;format attempt:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;value&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; $ monthnew &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'10'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; =&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'OCT'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;month = month(input(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;year = year(input(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'month'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,compress(put(month,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;monthnew.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;)));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'year'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,compress(put(year,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;best.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;)));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;year;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;month; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2016 11:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/304329#M64783</guid>
      <dc:creator>Dumitru86</dc:creator>
      <dc:date>2016-10-13T11:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/316323#M69097</link>
      <description>&lt;P&gt;I'd like to automate a YTD report that pulls data from January to December every year.&amp;nbsp; There is always a 1-month lag.&lt;/P&gt;&lt;P&gt;Run date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date parameter for data&lt;/P&gt;&lt;P&gt;December 2016&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; January to November 2016&lt;/P&gt;&lt;P&gt;January 2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; January to December 2016&lt;/P&gt;&lt;P&gt;February 2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;January to January 2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any code you can share is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 17:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/316323#M69097</guid>
      <dc:creator>may888</dc:creator>
      <dc:date>2016-12-02T17:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month and year from %sysdate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/316359#M69112</link>
      <description>Instead of re-activating a zombie topic, start a new one, using appropriate title.</description>
      <pubDate>Fri, 02 Dec 2016 19:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-month-and-year-from-sysdate/m-p/316359#M69112</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-02T19:21:49Z</dc:date>
    </item>
  </channel>
</rss>

