<?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: Syntax error in numeric expression? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386378#M92522</link>
    <description>&lt;P&gt;Great, you have tried the code suggested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, let's go further ... it was also suggested that you SHOW US YOUR DATA (or at least, a relevant portion of your data). I think that's the only way we are going to get you an answer.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2017 19:20:14 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2017-08-08T19:20:14Z</dc:date>
    <item>
      <title>Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386293#M92489</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a code below,&amp;nbsp; and I received an error message from log.&amp;nbsp; Please advice how to fix it, thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if stateid ^=. then productID+1;&lt;/P&gt;
&lt;P&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 15:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386293#M92489</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-08-08T15:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386297#M92491</link>
      <description>&lt;P&gt;productID seems to be a character variable. convert it to numeric using the INPUT function &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://sasnrd.com/convert-character-numeric/" target="_blank"&gt;http://sasnrd.com/convert-character-numeric/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Sep 2017 18:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386297#M92491</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-17T18:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386299#M92492</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;productID seems to be a character variable. &lt;FONT color="#ff0000"&gt;convert it to numeric using the INPUT function&lt;/FONT&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think that will work.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 15:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386299#M92492</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-08-08T15:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386301#M92493</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;productID seems to be a character variable. &lt;FONT color="#ff0000"&gt;convert it to numeric using the INPUT function&lt;/FONT&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think that will work.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course, the original poster has not told us what ProductID contains, but it is highly suspicious from a logical point of view that adding one to productID makes any sense at all.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 15:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386301#M92493</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-08-08T15:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386309#M92495</link>
      <description>&lt;P&gt;There is no ProductID column in the table 'have',&amp;nbsp;&amp;nbsp; I would like to create one when the StateID is not blank, and the new generated column ProductID is the same as StateID.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 15:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386309#M92495</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-08-08T15:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386322#M92498</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;There is no ProductID column in the table 'have',&amp;nbsp;&amp;nbsp; I would like to create one when the StateID is not blank, and the new generated column ProductID is the same as StateID.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That sounds like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not missing(stateid) then ProductId=StateId;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, showing input data and desired output may clarify what you are actually attempting.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 16:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386322#M92498</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-08T16:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386326#M92500</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;There is no ProductID column in the table 'have',&amp;nbsp;&amp;nbsp; I would like to create one when the StateID is not blank, and the new generated column ProductID is the same as StateID.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If that is true the the error is for the other variable in your statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if stateid ^=. then productID+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your code is treating STATEID as if it was a number, so SAS tried to convert the value to a number. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the MISSING() function which does not care what type of variable you give it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If not missing(stateid) then ProductId+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you want PRODUCTID to be the same as STATEID it seems you just want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ProductId = coalescec(stateid,ProductId);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 16:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386326#M92500</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-08T16:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386369#M92519</link>
      <description>&lt;P&gt;I have tried both of the codes, none of them was working.&amp;nbsp; All of the StateID are numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;925 data allstaterename1; set allstaterename;&lt;/P&gt;
&lt;P&gt;926 If mrs_stateid ^=. then momID+1;&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;400&lt;/P&gt;
&lt;P&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;
&lt;P&gt;927 /* If not missing (nad_stateid) then childID+2;*/ run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;928 data allstaterename1; set allstaterename;&lt;/P&gt;
&lt;P&gt;929 /*If mrs_stateid ^=. then momID+1;*/&lt;/P&gt;
&lt;P&gt;930 If not missing (nad_stateid) then childID+2; run;&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;400&lt;/P&gt;
&lt;P&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 19:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386369#M92519</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-08-08T19:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386375#M92521</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have tried both of the codes, none of them was working.&amp;nbsp; All of the StateID are numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;925 data allstaterename1; set allstaterename;&lt;/P&gt;
&lt;P&gt;926 If mrs_stateid ^=. then momID+1;&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;400&lt;/P&gt;
&lt;P&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;
&lt;P&gt;927 /* If not missing (nad_stateid) then childID+2;*/ run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;928 data allstaterename1; set allstaterename;&lt;/P&gt;
&lt;P&gt;929 /*If mrs_stateid ^=. then momID+1;*/&lt;/P&gt;
&lt;P&gt;930 If not missing (nad_stateid) then childID+2; run;&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;400&lt;/P&gt;
&lt;P&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You cannot use the SUM statement like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;momID+1;
childID+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with character variables.&lt;/P&gt;
&lt;P&gt;So either use a different variable name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;momID_number+1;
childID_number+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use the DROP= or RENAME= dataset options on the input dataset to get the old variable out of the way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; set allstaterename(drop=momID);
 set allstaterename(rename=(momID=old_momID));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 19:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386375#M92521</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-08T19:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386378#M92522</link>
      <description>&lt;P&gt;Great, you have tried the code suggested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, let's go further ... it was also suggested that you SHOW US YOUR DATA (or at least, a relevant portion of your data). I think that's the only way we are going to get you an answer.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 19:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386378#M92522</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-08-08T19:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in numeric expression?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386383#M92526</link>
      <description>&lt;P&gt;Thanks for everone's prompt replies and great suggestions.&amp;nbsp; It works.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 19:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-numeric-expression/m-p/386383#M92526</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-08-08T19:33:59Z</dc:date>
    </item>
  </channel>
</rss>

