<?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: Create a macro to hold 1jan2017 using sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360555#M84914</link>
    <description>&lt;P&gt;Or you can even avoid using the unsatisfying %sysfunc(intnx(...)) syntax by treating &amp;amp;sysdate9 as the text that it is:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let mydate=01jan%substr(&amp;amp;sysdate9,6,4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, I would not include the quotes in&amp;nbsp;macrovar value.&amp;nbsp; Instead, when the date value is needed, I'd use "&amp;amp;mydate"d.&amp;nbsp; It makes the&amp;nbsp;type of value in&amp;nbsp;the macrovar more apparent in the sas code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if one absolutely must use&amp;nbsp;proc sql, you apparently have to have a "from" dataset even though no dataset content is being used (perhaps that's the point of being required to use SQL?).&amp;nbsp; I couldn't find a way to avoid the FROM clause below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Sasfont"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; select&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; cats(&lt;/FONT&gt;&lt;FONT color="#800080" face="Sasfont"&gt;'01jan'&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;,substr(&lt;/FONT&gt;&lt;FONT color="#800080" face="Sasfont"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;)) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;into&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; :mymac &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;from&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; sashelp.class ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 May 2017 20:54:33 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-05-22T20:54:33Z</dc:date>
    <item>
      <title>Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360533#M84903</link>
      <description>&lt;P&gt;Todays date is 5/23/2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a macro to hold 01/Jan/2017. Using SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 19:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360533#M84903</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-05-22T19:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360534#M84904</link>
      <description>&lt;P&gt;So let's clarify something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You asked for a macro that holds a text string. Do you mean you want a macro VARIABLE that holds a text string?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does it have to be SQL? This is trivial to do without SQL whether you want a macro or a macro variable.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 19:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360534#M84904</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-05-22T19:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360535#M84905</link>
      <description>Hey there. Yes. I would like to hold this date 01JAN2017.&lt;BR /&gt;&lt;BR /&gt;SQL because I was asked to do it using SQL. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; I wont mind other ways too.</description>
      <pubDate>Mon, 22 May 2017 19:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360535#M84905</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-05-22T19:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360536#M84906</link>
      <description>&lt;P&gt;You didn't answer my question about whether or not you want a macro or a macro variable. "Yes" does not answer the question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if you want a macro variable, try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let date=01jan2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why bother with SQL?&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 19:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360536#M84906</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-05-22T19:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360538#M84907</link>
      <description>&lt;P&gt;The form for a date literal is quoted date in DATE format with the letter D after it.&lt;/P&gt;
&lt;P&gt;To create a macro variable use the %LET macro statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar='01JAN2017'd;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to calculate the first day of the current year use the INTNX() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar="%sysfunc(intnx(year,"&amp;amp;sysdate9"d,b),date9)"d;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 May 2017 19:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360538#M84907</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-22T19:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360542#M84909</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, that's the answer if the&amp;nbsp;question asks for a SAS date value, which as far as I can read, was not requested. The question asks for the&amp;nbsp;text 01JAN2017&amp;nbsp;to be included in a macro (or macro variable, it's not really clear).&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 20:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360542#M84909</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-05-22T20:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360547#M84911</link>
      <description>My bad. Needed a macro. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 22 May 2017 20:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360547#M84911</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-05-22T20:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360555#M84914</link>
      <description>&lt;P&gt;Or you can even avoid using the unsatisfying %sysfunc(intnx(...)) syntax by treating &amp;amp;sysdate9 as the text that it is:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let mydate=01jan%substr(&amp;amp;sysdate9,6,4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, I would not include the quotes in&amp;nbsp;macrovar value.&amp;nbsp; Instead, when the date value is needed, I'd use "&amp;amp;mydate"d.&amp;nbsp; It makes the&amp;nbsp;type of value in&amp;nbsp;the macrovar more apparent in the sas code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if one absolutely must use&amp;nbsp;proc sql, you apparently have to have a "from" dataset even though no dataset content is being used (perhaps that's the point of being required to use SQL?).&amp;nbsp; I couldn't find a way to avoid the FROM clause below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Sasfont"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Sasfont"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;&amp;nbsp; select&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; cats(&lt;/FONT&gt;&lt;FONT color="#800080" face="Sasfont"&gt;'01jan'&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;,substr(&lt;/FONT&gt;&lt;FONT color="#800080" face="Sasfont"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Sasfont"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Sasfont"&gt;)) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;into&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; :mymac &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;from&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; sashelp.class ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Sasfont"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 20:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/360555#M84914</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-22T20:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create a macro to hold 1jan2017 using sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/361743#M85360</link>
      <description>Quite late to reply. But thanks mate. This is what i was looking for. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 25 May 2017 19:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-macro-to-hold-1jan2017-using-sql/m-p/361743#M85360</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-05-25T19:06:02Z</dc:date>
    </item>
  </channel>
</rss>

