<?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: excluding 0 from after a decimal in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335338#M75885</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Removing leading and trailing 0s and blanks from a numeric variable(from display or char variable)

Be careful 'proc print' and 'put' can be decieving

HAVE
====

1.0
12.30
11.07
7.70
0.0
17.71

WANT
====

1
12.3
11.07
7.7
0
17.71

But I get when surrounding my put statement with '*'

*1*
*           1*
*           1*
*1           *


WANTED
======

*1* or just 1

WORKING CODE
============

    Thanks to data _null_ old post
    CutZro=substrn(a[i],1,max(5,a[i]));

FULL SOLUTION
=============

data chrCutZro;
  length CutZro $5;
  array A[6]  (1.0, 12.30, 11.07, 7.70, 0.0, 17.71);
  do i=1 to 6;
     CutZro=substrn(a[i],1,max(5,a[i]));
     put '*' CutZro +(-1) '*';
     put '*' a[i] best.  '*';
     leading_blanks=put(a[i],best.);
     put '*' leading_blanks $char12. '*';
     leading_blanks_left=put(a[i],best. -l);
     put '*' leading_blanks_left $char12. '*';
  end;
run;quit;


substrn   *1*
best.     *           1*
char12    *           1*
best -L   *1           *

substrn   *12.3*
best.     *        12.3*
char12    *        12.3*
best -L   *12.3        *

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Feb 2017 16:22:29 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2017-02-23T16:22:29Z</dc:date>
    <item>
      <title>excluding 0 from after a decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335293#M75871</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to give required auto format to a NUMERIC variable in a datastep(without&amp;nbsp;Macros)&lt;/P&gt;&lt;P&gt;For eg:&lt;/P&gt;&lt;P&gt;Numaric Variable values are as follow&lt;/P&gt;&lt;P&gt;A = 1.0, 12.30, 11.07, 7.70, 0.0, 17.71&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want them to be like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Numeric, B = 1, 12.3, 11.07, 7.7, 0, &amp;nbsp;17.71&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 14:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335293#M75871</guid>
      <dc:creator>ysantosh18</dc:creator>
      <dc:date>2017-02-23T14:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: excluding 0 from after a decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335298#M75873</link>
      <description>&lt;P&gt;Doe the "best." format not&amp;nbsp;give you what you want?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;do A = 1.0, 12.30, 11.07, 7.70, 0.0, 17.71;&lt;BR /&gt;put a 8.2 a best.;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 15:00:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335298#M75873</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-02-23T15:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: excluding 0 from after a decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335302#M75874</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works absolutely fine&lt;/P&gt;&lt;P&gt;Thank you So much!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 15:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335302#M75874</guid>
      <dc:creator>ysantosh18</dc:creator>
      <dc:date>2017-02-23T15:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: excluding 0 from after a decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335338#M75885</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Removing leading and trailing 0s and blanks from a numeric variable(from display or char variable)

Be careful 'proc print' and 'put' can be decieving

HAVE
====

1.0
12.30
11.07
7.70
0.0
17.71

WANT
====

1
12.3
11.07
7.7
0
17.71

But I get when surrounding my put statement with '*'

*1*
*           1*
*           1*
*1           *


WANTED
======

*1* or just 1

WORKING CODE
============

    Thanks to data _null_ old post
    CutZro=substrn(a[i],1,max(5,a[i]));

FULL SOLUTION
=============

data chrCutZro;
  length CutZro $5;
  array A[6]  (1.0, 12.30, 11.07, 7.70, 0.0, 17.71);
  do i=1 to 6;
     CutZro=substrn(a[i],1,max(5,a[i]));
     put '*' CutZro +(-1) '*';
     put '*' a[i] best.  '*';
     leading_blanks=put(a[i],best.);
     put '*' leading_blanks $char12. '*';
     leading_blanks_left=put(a[i],best. -l);
     put '*' leading_blanks_left $char12. '*';
  end;
run;quit;


substrn   *1*
best.     *           1*
char12    *           1*
best -L   *1           *

substrn   *12.3*
best.     *        12.3*
char12    *        12.3*
best -L   *12.3        *

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2017 16:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/excluding-0-from-after-a-decimal/m-p/335338#M75885</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-02-23T16:22:29Z</dc:date>
    </item>
  </channel>
</rss>

