<?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: Getting error when reformatting character data type to numeric data type if a value is not enter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257668#M49488</link>
    <description>&lt;P&gt;You could try using %SYSFUNC and inputn/putn.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let FGR = 3903918260;&lt;BR /&gt;%let NEW_FGR = %sysfunc(putn(&amp;amp;FGR,comma16.)); &lt;BR /&gt;%put NEW_FGR is: *** &amp;amp;NEW_FGR ***;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output the following to the Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NEW_FGR is: *** 3,903,918,260 ***&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Mar 2016 17:10:01 GMT</pubDate>
    <dc:creator>moorsd</dc:creator>
    <dc:date>2016-03-18T17:10:01Z</dc:date>
    <item>
      <title>Getting error when reformatting character data type to numeric data type if a value is not entered.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257654#M49478</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have several prompts, 'FGR', 'DATA1' &amp;amp; DATA2'.&amp;nbsp; This data is character so I defined the prompt in SMC as character type.&amp;nbsp; However, I need to compare to a numeric value so in my code I am using 'call symput' to convert to a numeric value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I am finding in testing is that if I have a value in the prompt, the code works.&amp;nbsp; However, the user may only enter one value and leave the other 2 blank.&amp;nbsp; In my example I have entered a value into 'FGR' but left 'DATA1' &amp;amp; 'DATA2' blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions would be greatly appreciated.&lt;/P&gt;
&lt;PRE&gt;80            Call symput(('NEW_FGR),(input(&amp;amp;FGR,16.)));
82            Call symput(('NEW_DATA1'),(input(&amp;amp;DATA1,16.)));
                                                     _
                                                     22
83                Call symput(('NEW_DATA2'),(input(&amp;amp;DATA,16.)));
                                                        _
                                                        22
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, 
              a missing value, INPUT, PUT.  
              a missing value, INPUT, PUT.
&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Mar 2016 16:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257654#M49478</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2016-03-18T16:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Getting error when reformatting character data type to numeric data type if a value is not enter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257655#M49479</link>
      <description>&lt;P&gt;CALL SYMPUT creates a macro variable that will always be text.&lt;/P&gt;
&lt;P&gt;Please post an example of how resolving the macro variable is causing issues and we can make suggestions on how to resolve it.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 16:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257655#M49479</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-18T16:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Getting error when reformatting character data type to numeric data type if a value is not enter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257659#M49482</link>
      <description>&lt;P&gt;Not sure I understand what you want me to post.&amp;nbsp; I posted the source code that I am using to convert the character to numeric value.&amp;nbsp; Since you mentioned that 'call symput' returns a text value then I do not need to use it, I want numeric returned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried another way to assign the converted character to numeric value to a variable by doing this:&lt;/P&gt;
&lt;P&gt;%let NEW_FGR = input(&amp;amp;FGR,16.);&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used a put statement to display 'NEW_FGR' and this is what was returned:&lt;/P&gt;
&lt;P&gt;116&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;%put &amp;amp;NEW_FGR_FROM_AMT;&lt;/P&gt;
&lt;P&gt;input(3903918260,16.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It appears that it did not apply the 'input' to convert from char to numeric but rather used the whole string as the new value for 'NEW_FGR'.&amp;nbsp;&amp;nbsp; This seems like it be easy to do just to convert to numeric and assign to a variable but I just can't seem to get it right!&amp;nbsp; I have spent several hours on this!!!&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;</description>
      <pubDate>Fri, 18 Mar 2016 16:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257659#M49482</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2016-03-18T16:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Getting error when reformatting character data type to numeric data type if a value is not enter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257665#M49485</link>
      <description>&lt;P&gt;Where are you trying to use those macro variables?&lt;/P&gt;
&lt;P&gt;Creating new macro variables will not change the type, it changes the appearance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All macro variables are text - how you use them is what matters.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 16:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257665#M49485</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-18T16:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Getting error when reformatting character data type to numeric data type if a value is not enter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257666#M49486</link>
      <description>&lt;P&gt;Reeza has hit on the right issue here. &amp;nbsp;Your macro variables are fine. &amp;nbsp;It's how you use them later that matters. &amp;nbsp;To give you an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let year = 2016;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;YEAR is always the set of characters: &amp;nbsp;2016&lt;/P&gt;
&lt;P&gt;SAS will see how you use &amp;amp;YEAR, and make a determination as to whether they are text of a number. &amp;nbsp;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data fy&amp;amp;year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS decides that 2016 is text, and "fy2016" is the name of the data set to create.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;next_year = &amp;amp;year + 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS decides that 2016 is numeric, ans uses it to perform math. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In both cases, SAS is deciding whether to treat the characters as text or as numeric. &amp;nbsp;Macro langauge is not deciding.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 17:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257666#M49486</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-18T17:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting error when reformatting character data type to numeric data type if a value is not enter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257668#M49488</link>
      <description>&lt;P&gt;You could try using %SYSFUNC and inputn/putn.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let FGR = 3903918260;&lt;BR /&gt;%let NEW_FGR = %sysfunc(putn(&amp;amp;FGR,comma16.)); &lt;BR /&gt;%put NEW_FGR is: *** &amp;amp;NEW_FGR ***;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output the following to the Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NEW_FGR is: *** 3,903,918,260 ***&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 17:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-error-when-reformatting-character-data-type-to-numeric/m-p/257668#M49488</guid>
      <dc:creator>moorsd</dc:creator>
      <dc:date>2016-03-18T17:10:01Z</dc:date>
    </item>
  </channel>
</rss>

