<?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: Converting numeric to character AND retain comma and neg sign in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858857#M339340</link>
    <description>I guess when I'm tired I over-think it. Thanks so much for the help!</description>
    <pubDate>Wed, 15 Feb 2023 01:41:27 GMT</pubDate>
    <dc:creator>SASGeek</dc:creator>
    <dc:date>2023-02-15T01:41:27Z</dc:date>
    <item>
      <title>Converting numeric to character AND retain comma and neg sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858838#M339327</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;I have a column of values that are between 2-5 digits to the left of the decimal and two to the right of the decimal. What I want is to convert the number to a character but keep the comma and negative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the following and it comes close but not 100%. I need it into character for use in other places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data Mine;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;a = -4502.25;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;b = put(a,8.2);&amp;nbsp; &amp;nbsp; &amp;nbsp;/* this results in -4502.25 not -4,502.25 */&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 21:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858838#M339327</guid>
      <dc:creator>SASGeek</dc:creator>
      <dc:date>2023-02-14T21:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric to character AND retain comma and neg sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858839#M339328</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/93090"&gt;@SASGeek&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p0sad1pg4gsni3n1gbjue9fxzyhq.htm" target="_blank" rel="noopener"&gt;COMMA&lt;EM&gt;w&lt;/EM&gt;.&lt;EM&gt;d&lt;/EM&gt; format&lt;/A&gt; will add the comma, provided that the width (&lt;EM&gt;w&lt;/EM&gt;) is sufficient. You need &lt;EM&gt;w&lt;/EM&gt;=10 for minus sign, 5+2 digits, comma and decimal point.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;b = put(a,comma10.2);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Feb 2023 21:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858839#M339328</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-02-14T21:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric to character AND retain comma and neg sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858852#M339336</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/93090"&gt;@SASGeek&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;I have a column of values that are between 2-5 digits to the left of the decimal and two to the right of the decimal. What I want is to convert the number to a character but keep the comma and negative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the following and it comes close but not 100%. I need it into character for use in other places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data Mine;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;a = -4502.25;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;b = put(a,8.2);&amp;nbsp; &amp;nbsp; &amp;nbsp;/* this results in -4502.25 not -4,502.25 */&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure what you mean by "retain".&amp;nbsp; Does the numeric variable currently display with thousand separators?&amp;nbsp; Check what FORMAT is attached and use the same format.&amp;nbsp; Or use the VVALUE() function and SAS will apply the format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length charvar $32 ;
  charvar=vvalue(numvar);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To display 7 digits plus decimal place and optional negative sign and optional thousand's separator you will need 10 characters.&lt;/P&gt;
&lt;PRE&gt;1601  data test;
1602    a=-4502.25;
1603    b=put(a,comma10.2);
1604    put a= b= ;
1605  run;

a=-4502.25 b=-4,502.25
&lt;/PRE&gt;
&lt;P&gt;If you don't want the leading spaces in the variable B then either add the LEFT() function or add the -L modifier on the end of the format specification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 23:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858852#M339336</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-14T23:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting numeric to character AND retain comma and neg sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858857#M339340</link>
      <description>I guess when I'm tired I over-think it. Thanks so much for the help!</description>
      <pubDate>Wed, 15 Feb 2023 01:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-numeric-to-character-AND-retain-comma-and-neg-sign/m-p/858857#M339340</guid>
      <dc:creator>SASGeek</dc:creator>
      <dc:date>2023-02-15T01:41:27Z</dc:date>
    </item>
  </channel>
</rss>

