<?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 How to convert Character data with trailing sign to Numeric data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439914#M109809</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a requirement where the input is coming from the Easytrieve in which the acceptable numeric format is 100.00-. I need to convert this into&amp;nbsp; SAS numeric format. Can some one help me in achieving this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output&lt;/P&gt;
&lt;P&gt;100.00-&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -100.00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This field is the variable one.&lt;/P&gt;</description>
    <pubDate>Sat, 24 Feb 2018 18:46:29 GMT</pubDate>
    <dc:creator>SASInd</dc:creator>
    <dc:date>2018-02-24T18:46:29Z</dc:date>
    <item>
      <title>How to convert Character data with trailing sign to Numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439914#M109809</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a requirement where the input is coming from the Easytrieve in which the acceptable numeric format is 100.00-. I need to convert this into&amp;nbsp; SAS numeric format. Can some one help me in achieving this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Output&lt;/P&gt;
&lt;P&gt;100.00-&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -100.00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This field is the variable one.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 18:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439914#M109809</guid>
      <dc:creator>SASInd</dc:creator>
      <dc:date>2018-02-24T18:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character data to Numeric data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439923#M109814</link>
      <description>&lt;P&gt;You can define your own informat to read such numbers&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* Informat function to read numbers possibly suffixed with a
   minus sign. */ 
proc fcmp outlib=work.fcmp.format;
function EasytrieveNumber(text $);
m = indexc(text, "-");
if m = length(text) then return (-input(substr(text,1,m-1), best.));
else return (input(text, best.));
endsub;
run;

options cmplib=(work.fcmp);

proc format;
invalue EasytrieveNumber(default=32) 
OTHER = [EasytrieveNumber()];
run;

data have;
input a :EasytrieveNumber10.;
format a 8.2;
cards;
100.00-
100.00
;

proc print data=have; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                  Obs           a

                                   1      -100.00
                                   2       100.00
&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Feb 2018 05:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439923#M109814</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-24T05:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character data to Numeric data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439926#M109815</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
input x trailsgn32.;
cards;
100.00-   
34.32-
29
64.89
;
run;
proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Feb 2018 06:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439926#M109815</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-02-24T06:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character data to Numeric data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439928#M109816</link>
      <description>&lt;P&gt;Hi Ksharp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TRAILSGNw. will only work for numeric values. In this case the input is coming as 100.00- which in my knowledge will only be read as a character value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 07:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439928#M109816</guid>
      <dc:creator>SASInd</dc:creator>
      <dc:date>2018-02-24T07:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character data to Numeric data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439955#M109825</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194299"&gt;@SASInd&lt;/a&gt;: &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; demonstrates that the format can be used to create normal numbers.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 16:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439955#M109825</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-02-24T16:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character data to Numeric data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439956#M109826</link>
      <description>Yeah... But the question here is for converting the character data to a numeric format.</description>
      <pubDate>Sat, 24 Feb 2018 16:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439956#M109826</guid>
      <dc:creator>SASInd</dc:creator>
      <dc:date>2018-02-24T16:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character data to Numeric data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439962#M109827</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@aadityapurohit3 wrote:&lt;BR /&gt;Yeah... But the question here is for converting the character data to a numeric format.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;solution does, you can use that format in the INPUT() statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
    input x $;
    cards;
100.00-   
34.32-
29
64.89
;
run;

data want;
    set x;
    char_x=input(x, trailsgn32.);
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Feb 2018 17:32:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/439962#M109827</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-24T17:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character data to Numeric data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/440415#M109996</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43025"&gt;@error_prone&lt;/a&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 09:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Character-data-with-trailing-sign-to-Numeric-data/m-p/440415#M109996</guid>
      <dc:creator>SASInd</dc:creator>
      <dc:date>2018-02-27T09:52:37Z</dc:date>
    </item>
  </channel>
</rss>

