<?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: intnx syntax error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606994#M176357</link>
    <description>&lt;P&gt;your problem (there may be others) is this line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year=(intnx(month,(today()),-1),year4.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Either you want a Put(n) kind of function before the intnx, or you have to drop the year4. part.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Nov 2019 14:59:06 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-25T14:59:06Z</dc:date>
    <item>
      <title>intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606984#M176353</link>
      <description>&lt;P&gt;Hi,Iam running below code and iam getting syntax error.&lt;BR /&gt;please help where iam going wrong please.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table work.W5V4AFV as
      select
         num,year,month
   from test
      where NOT 
         ( 
         year=(intnx(month,(today()),-1),year4.)/*i need 2019 */
         and
         month=(putn((intnx(month,(today()),-1),month2.),z2.))/* i need 10 value for month */
         )
         
          &amp;amp; 
         
         MDY(month,1,year) &amp;gt;= (intnx(month,(today()),-12,same),date9.) /*12 monrhs ago date */
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;34 and&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;35 month=(putn((intnx(month,(today()),-1),month2.),z2.))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;_ _ _&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;79 22 22&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;200&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 79-322: Expecting a ).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, *.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;36 )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;37 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;38 &amp;amp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;34 and&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;35 month=(putn((intnx(month,(today()),-1),month2.),z2.))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;_ _ _&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;79 22 22&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;200&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 79-322: Expecting a ).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, *.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;36 )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;37 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;38 &amp;amp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606984#M176353</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-25T14:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606994#M176357</link>
      <description>&lt;P&gt;your problem (there may be others) is this line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year=(intnx(month,(today()),-1),year4.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Either you want a Put(n) kind of function before the intnx, or you have to drop the year4. part.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606994#M176357</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-25T14:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606996#M176358</link>
      <description>&lt;P&gt;Typically, you would use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intnx('month',...)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where month is surrounded by single quotes (or double quotes, it doesn't matter here). Whether or not this fixes your problem or there are other problem, I don't know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the future, please be so kind as to include the entire log (not just the error messages) of this step by clicking on the &lt;FONT face="courier new,courier"&gt;{i}&lt;/FONT&gt; icon and pasting the log into the window that appears. This preserves formatting in the log and makes it easier to read.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 15:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606996#M176358</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-25T15:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606999#M176359</link>
      <description>&lt;P&gt;There appears to be two formats to be applied, viz. &lt;FONT face="courier new,courier"&gt;month2.&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;z2.&lt;/FONT&gt;, but there is only one &lt;FONT face="courier new,courier"&gt;putn()&lt;/FONT&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month=(putn((intnx(month,(today()),-1),month2.),z2.))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Have you tried using &lt;FONT face="courier new,courier"&gt;put()&lt;/FONT&gt; another time between the first contiguous open brackets "&lt;FONT face="courier new,courier"&gt;((&lt;/FONT&gt;":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month=(putn(put(intnx(month,(today()),-1),month2.),z2.))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 15:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/606999#M176359</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-11-25T15:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607000#M176360</link>
      <description>&lt;P&gt;What does your variable MONTH contain?&amp;nbsp; You are using it in the INTNX() as if it was a character variable that contains the type of interval that you want to increment your date by.&amp;nbsp; Like MONTH, DAY, YEAR, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the year from a date use the YEAR() function, similar for month use the MONTH() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table work.W5V4AFV as
      select
         num,year,month
   from test
   where NOT 
       ( year=year(intnx('month',today(),-1))
     and month=month(intnx('month',today(),-1))
       )
    and MDY(month,1,year) &amp;gt;= intnx('month',today(),-12,'same')
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 15:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607000#M176360</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-25T15:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607013#M176364</link>
      <description>&lt;P&gt;Since YEAR and MONTH are supposed to be in your data set, (the way they appear on the SELECT statement) then the question becomes are they numeric or character values?&lt;/P&gt;
&lt;P&gt;Of If the variables Year and Month are NOT already in the data set then you have a LOT of basic SQL issues to address.&lt;/P&gt;
&lt;P&gt;Such as do you want Year and Month to be numeric or character variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At this point I strongly suggest posting an example of your existing data and what you expect for an output for that given data.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 15:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607013#M176364</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-25T15:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607204#M176440</link>
      <description>&lt;P&gt;Hi All,sorry for confusion.&lt;BR /&gt;Iam running below code to create year and month which is giving desired values what i need for year and month.&lt;BR /&gt;but i don't want to use "%sysfunc".i tried by removing the %sysfunc.i am constantly getting the posted syntax error.please help&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table work.W5WITF2 as
      select
         Num length = 10,
         
         (%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1),month2.),z2.))) as Month length = 3
            format = Z2.
            label = 'Month',
         (%sysfunc(intnx(month,%sysfunc(today()),-1),year4.)) as  length = 3
            format = Z4.
            label = 'Year'
         
   from work.W5WITF2;

   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 07:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607204#M176440</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-26T07:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607218#M176451</link>
      <description>&lt;P&gt;You need to understand the differences between the value of a variable and the displayed (aka formatted) value. A numeric variable doesn't have leading zeros, but the format z2 can be used to display the variable with leading zeros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following step seems to create what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.W5WITF2;
   length Month Year LastMonth 8;
   drop LastMonth;

   format 
      Month z2. 
      Year z4. /* useless, because the year has almost always four digits */
   ;

   LastMonth = intnx('month', today(), -1);
   Month = month(LastMonth);
   Year = year(LastMonth);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,sorry for confusion.&lt;BR /&gt;Iam running below code to create year and month which is giving desired values what i need for year and month.&lt;BR /&gt;but i don't want to use "%sysfunc".i tried by removing the %sysfunc.i am constantly getting the posted syntax error.please help&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table work.W5WITF2 as
      select
         Num length = 10,
         
         (%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1),month2.),z2.))) as Month length = 3
            format = Z2.
            label = 'Month',
         (%sysfunc(intnx(month,%sysfunc(today()),-1),year4.)) as  length = 3
            format = Z4.
            label = 'Year'
         
   from work.W5WITF2;

   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 07:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607218#M176451</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-11-26T07:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607254#M176470</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;iam following as you suggetsed and ran below code,for month it is working as expected,but year iam getting 1960.i need year value should be 2019 please(last month's year).please help&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
h=month(intnx('month', today(), -1));
y=year(h);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Ouput coming as below :&lt;/P&gt;&lt;P&gt;10 1960&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Needed Ouput should be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;10 2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried below option also(actually last_month and month and i need to do it in single line code please,please help )&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.W5WITF2;
   length Month Year LastMonth 8;
   drop LastMonth;

   format 
      Month z2. 
      Year z4. /* useless, because the year has almost always four digits */
   ;

   
   Month = month(intnx('month', today(), -1));
   Year = year(Month);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 10:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607254#M176470</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-26T10:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607315#M176502</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;can anyone help please&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 12:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607315#M176502</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-26T12:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607327#M176512</link>
      <description>&lt;P&gt;The functions year and month expect a date as parameter and return the number of year/month, so you can't use the value returned by the function month as parameter for year.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 13:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607327#M176512</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-11-26T13:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607332#M176517</link>
      <description>&lt;P&gt;Iam sorry i did not understand.i need to create previous_month ,current_yeat to be creating using single line code,&lt;BR /&gt;Actually iam using below one line code it is working fine.but i just want to find out other option with out 2 line code please.&lt;BR /&gt;you mean it is not possible please ?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1),month2.),z2.))
%sysfunc(intnx(month,%sysfunc(today()),-1),year4.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 13:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607332#M176517</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-26T13:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607338#M176521</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Iam sorry i did not understand.i need to create previous_month ,current_yeat to be creating using single line code,&lt;BR /&gt;Actually iam using below one line code it is working fine.but i just want to find out other option with out 2 line code please.&lt;BR /&gt;you mean it is not possible please ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1),month2.),z2.))
%sysfunc(intnx(month,%sysfunc(today()),-1),year4.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want to set two variables (month and year) you will have to use two statements. You have posted two lines of code, so i don't understand the requirement of having all in a single line. Maybe we should get back to the beginning: what do you really need as result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 13:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607338#M176521</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-11-26T13:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607344#M176525</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Iam sorry i did not understand.i need to create previous_month ,current_yeat to be creating using single line code,&lt;BR /&gt;Actually iam using below one line code it is working fine.but i just want to find out other option with out 2 line code please.&lt;BR /&gt;you mean it is not possible please ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1),month2.),z2.))
%sysfunc(intnx(month,%sysfunc(today()),-1),year4.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why are you posting macro code on this thread?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to generate one macro variable?&lt;/P&gt;
&lt;P&gt;Do you want to generate two macro variables?&lt;/P&gt;
&lt;P&gt;How are you going to use those generated values to help you generate actual SAS code?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 13:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607344#M176525</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-26T13:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607346#M176526</link>
      <description>&lt;P&gt;You asked the YEAR() function to extract the year from a date value of 10. Since SAS counts days from 1960 the number 10 is the date '10JAN1960'd.&amp;nbsp; So it did exactly what you asked it to do.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 13:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607346#M176526</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-26T13:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: intnx syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607348#M176527</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,sorry for confusion.&lt;BR /&gt;Iam running below code to create year and month which is giving desired values what i need for year and month.&lt;BR /&gt;but i don't want to use "%sysfunc".i tried by removing the %sysfunc.i am constantly getting the posted syntax error.please help&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table work.W5WITF2 as
      select
         Num length = 10,
         
         (%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1),month2.),z2.))) as Month length = 3
            format = Z2.
            label = 'Month',
         (%sysfunc(intnx(month,%sysfunc(today()),-1),year4.)) as  length = 3
            format = Z4.
            label = 'Year'
         
   from work.W5WITF2;

   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;%SYSFUNC() is a macro function that allows you to call a normal SAS function in macro code.&amp;nbsp; Once the macro processor finishes evaluating the macro expression the resulting text is passed onto SAS to process.&amp;nbsp; One way to help you debug the code is to remove the macro code and just replace it with the text it would generate and then you can debug that code. Once you have the SAS code debugged you can replace the text with the macro code that generates the text and start debugging the macro aspects of your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So here is your code with the macro function call replaced with representative values.&amp;nbsp; I also cleaned up the formatting a little to make it a little easier to read.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table work.W5WITF2 as
  select 
    Num length = 10
  , (10) as Month length = 3 format = Z2. label = 'Month'
  , (2019) as  length = 3 format = Z4. label = 'Year'
  from work.W5WITF2
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's review the three variables you are defining in the SELECT clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First you are taking the variable NUM and changing its length to 10.&amp;nbsp; &lt;STRONG&gt;So NUM must be a character variable that is in the dataset WSWITF2 since the maximum length that SAS can use to store a numeric variable is the full 8 bytes that the floating point numbers SAS uses require.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next you are storing the number 10, the extra parentheses around the value do not change it, and are calling MONTH. You are telling SAS to display it as two digits with leading zeros.&amp;nbsp; You are telling it that the label is the same as the name (why attach a label if it is just going to have the same value as the name?).&amp;nbsp; You are also telling it remove the 5 least significant bytes from the value when storing it into the dataset.&amp;nbsp; That should be fine if the value is only ever the integers 1 to 12.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next you are trying to do the same thing with the number 2019, but in this case &lt;STRONG&gt;you forgot to give SAS name for this variable.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 14:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-syntax-error/m-p/607348#M176527</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-26T14:15:52Z</dc:date>
    </item>
  </channel>
</rss>

