<?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: SAS:how to extract year/month/date from a marco variable and add an integer? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455452#M115205</link>
    <description>&lt;P&gt;thank you for your answer..I want to let them work in the data step,like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;if year("&amp;amp;date01"d)=year("&amp;amp;date02"d)=year("&amp;amp;date03"d)&lt;/P&gt;&lt;P&gt;then...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Apr 2018 02:29:11 GMT</pubDate>
    <dc:creator>Geo-</dc:creator>
    <dc:date>2018-04-19T02:29:11Z</dc:date>
    <item>
      <title>SAS:how to extract year/month/date from a marco variable and add an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455449#M115203</link>
      <description>&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select max(data_bsn_dt) into:date01 from tableA;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;date02;&lt;/P&gt;&lt;P&gt;print out:31DEC2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put year("&amp;amp;date01"d);&lt;/P&gt;&lt;P&gt;print out:year("31DEC2017"d)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used code:year("&amp;amp;date01"d) to extract year or month before,but it does not work now..could some have time solve,thanks.&lt;/P&gt;&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;Even in the data step,it still not working..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data _nulll;
if year("&amp;amp;date01"d)=2017
then call execute('proc sql;
                   select * from tableB;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2018 02:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455449#M115203</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-04-19T02:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS:how to extract year/month/date from a marco variable and add an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455450#M115204</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; month&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;month&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&amp;amp;&lt;SPAN&gt;date01&lt;/SPAN&gt;"&lt;/SPAN&gt;d&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; year&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&amp;amp;&lt;SPAN&gt;date01&lt;/SPAN&gt;"&lt;/SPAN&gt;d&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2018 02:25:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455450#M115204</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-19T02:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS:how to extract year/month/date from a marco variable and add an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455452#M115205</link>
      <description>&lt;P&gt;thank you for your answer..I want to let them work in the data step,like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;if year("&amp;amp;date01"d)=year("&amp;amp;date02"d)=year("&amp;amp;date03"d)&lt;/P&gt;&lt;P&gt;then...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 02:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455452#M115205</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-04-19T02:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS:how to extract year/month/date from a marco variable and add an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455453#M115206</link>
      <description>&lt;P&gt;&lt;BR /&gt;1 %let date01=31DEC2017;&lt;BR /&gt;2&lt;BR /&gt;3 data _nulll;&lt;BR /&gt;4 if year("&amp;amp;date01"d)=2017&lt;BR /&gt;5 then put 'ok';&lt;BR /&gt;6 run;&lt;/P&gt;&lt;P&gt;ok&lt;BR /&gt;NOTE: The data set WORK._NULLL has 1 observations and 0 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.34 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;works fine&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 02:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455453#M115206</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-19T02:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS:how to extract year/month/date from a marco variable and add an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455462#M115207</link>
      <description>&lt;P&gt;Your PROC SQL is missing a QUIT but your code appears correct otherwise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure that’s what your macro variable is resolving to? Sometimes it’s not formatted and I can see that causing issues. Given you haven’t specified a format I’m pretty sure that’s what’s happening here, see test below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2A7B2DBF-A05A-4DB5-84C4-B3F985E4F30B.jpeg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19957iEAF4F2415AAA049A/image-size/large?v=v2&amp;amp;px=999" role="button" title="2A7B2DBF-A05A-4DB5-84C4-B3F985E4F30B.jpeg" alt="2A7B2DBF-A05A-4DB5-84C4-B3F985E4F30B.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184018"&gt;@Geo-&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select max(data_bsn_dt) into:date01 from tableA;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;date02;&lt;/P&gt;
&lt;P&gt;print out:31DEC2017&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put year("&amp;amp;date01"d);&lt;/P&gt;
&lt;P&gt;print out:year("31DEC2017"d)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used code:year("&amp;amp;date01"d) to extract year or month before,but it does not work now..could some have time solve,thanks.&lt;/P&gt;
&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;Even in the data step,it still not working..&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;data _nulll;
if year("&amp;amp;date01"d)=2017
then call execute('proc sql;
                   select * from tableB;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 03:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455462#M115207</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-19T03:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS:how to extract year/month/date from a marco variable and add an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455483#M115213</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select max(data_bsn_dt) into:date01 from tableA;
quit;

data _null_;
if year(&amp;amp;date01) = 2017
then call execute('proc sql; select * from tableB;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In your example, you are %PUTting variable &amp;amp;date02 for control, but you use &amp;amp;date01 later in the code. %put &amp;amp;date01 and inspect it.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 07:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-how-to-extract-year-month-date-from-a-marco-variable-and-add/m-p/455483#M115213</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-19T07:16:16Z</dc:date>
    </item>
  </channel>
</rss>

