<?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 Removing Decimal Points in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27495#M5041</link>
    <description>All,&lt;BR /&gt;
&lt;BR /&gt;
Is there an easy way to remove decimal points from data? I have variables yvar1-yvar24 that I want to output to a text file without decimal points.&lt;BR /&gt;
&lt;BR /&gt;
the data might be 2.12 or .801 and I'd like them to be 212 and 801. Is there any way to take out the decimal places either before or during the export? Thanks.</description>
    <pubDate>Tue, 02 Nov 2010 20:28:21 GMT</pubDate>
    <dc:creator>Aar684</dc:creator>
    <dc:date>2010-11-02T20:28:21Z</dc:date>
    <item>
      <title>Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27495#M5041</link>
      <description>All,&lt;BR /&gt;
&lt;BR /&gt;
Is there an easy way to remove decimal points from data? I have variables yvar1-yvar24 that I want to output to a text file without decimal points.&lt;BR /&gt;
&lt;BR /&gt;
the data might be 2.12 or .801 and I'd like them to be 212 and 801. Is there any way to take out the decimal places either before or during the export? Thanks.</description>
      <pubDate>Tue, 02 Nov 2010 20:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27495#M5041</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-02T20:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27496#M5042</link>
      <description>You could use the compress function, e.g. yvar1=compress(yvar1,'.')</description>
      <pubDate>Tue, 02 Nov 2010 20:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27496#M5042</guid>
      <dc:creator>sf388</dc:creator>
      <dc:date>2010-11-02T20:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27497#M5043</link>
      <description>Presuming yours are SAS NUMERIC type variables, you can use a SAS assignment statement to create a uniquely-named SAS CHARACTER type variable using the COMPRESS function, as mentioned, but with a different SAS variable.  And, to avoid the SAS NOTE about conversion, use the PUT(&lt;VARNAME&gt;,BEST.) in your assignment surrounded by the COMPRESS.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
convert numeric character variable site:sas.com&lt;/VARNAME&gt;</description>
      <pubDate>Tue, 02 Nov 2010 21:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27497#M5043</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-02T21:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27498#M5044</link>
      <description>If your export uses a data step, then it can be adapted to compress the entire file buffer in a single compress()&lt;BR /&gt;
put varA varB varZ @;&lt;BR /&gt;
_file_= compress(_file_,'.');&lt;BR /&gt;
Put;</description>
      <pubDate>Wed, 03 Nov 2010 08:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27498#M5044</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-03T08:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27499#M5045</link>
      <description>Ok, first off thanks. Second, the compress function must be used with character variables? Can I use a put statement to convert yvar1-yvar24 at the same time to character variables or would I need to do them indiviually?</description>
      <pubDate>Wed, 03 Nov 2010 13:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27499#M5045</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-03T13:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27500#M5046</link>
      <description>of course you could compress after converting individually to char type.&lt;BR /&gt;
 converted = compress( put( yVar1, best10.), '.' );&lt;BR /&gt;
or&lt;BR /&gt;
converted = compress( vvalue(vYar1 ), '.' ) ;[pre]&lt;BR /&gt;
175  data ;&lt;BR /&gt;
176   retain yVar1 123.45 yVar2 456.789 ;&lt;BR /&gt;
177  converted1 = compress( put( yVar1, best10.), '.' );&lt;BR /&gt;
178  converted2 = compress( vvalue(yVar2 ), '.' ) ;&lt;BR /&gt;
179  put (_all_)(=/);&lt;BR /&gt;
180  run;&lt;BR /&gt;
&lt;BR /&gt;
yVar1=123.45&lt;BR /&gt;
yVar2=456.789&lt;BR /&gt;
converted1=12345&lt;BR /&gt;
converted2=456789&lt;BR /&gt;
NOTE: The data set WORK.DATA3 has 1 observations and 4 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):[/pre]&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
Trying to avoid that is why I suggested compressing periods out of the line just before you release it. Here is a saslog to demonstrate[pre]287  data test_data ;&lt;BR /&gt;
288    input  yVar1 - yVar24 ;&lt;BR /&gt;
289    format yVar: best18. ;&lt;BR /&gt;
290  list;cards ;&lt;BR /&gt;
&lt;BR /&gt;
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;BR /&gt;
291        12 123.4 2345.678 765.2 45678.1234 456 54678.456 1.45678 .3456 2345 12345 9843 12345678 5432.54 3456&lt;BR /&gt;
      101  7889045 .2345 23456789.6789 1234567890.32 23456.1234  123.3456 .345 3456.2345 .4567 1234567890.32 23&lt;BR /&gt;
      201  456.1234  123.3456 .345 3456.2345 .4567&lt;BR /&gt;
NOTE: The data set WORK.TEST_DATA has 1 observations and 24 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
292  ;&lt;BR /&gt;
293&lt;B&gt;&lt;BR /&gt;
294  data _null_ ;&lt;BR /&gt;
295     file 'no_dots.txt' dsd dlm='|' lrecl=10000 ; * pipe delimited output ;&lt;BR /&gt;
296     set ;             * load data ;&lt;BR /&gt;
297     put (yVar1-yVar20)(:)  @ ;    * prepare and hold output line ;&lt;BR /&gt;
298     _file_ = compress( _file_, '.' ) ;  * remove dots from line ;&lt;BR /&gt;
299     put ;                 * release line ;&lt;BR /&gt;
300  run ;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The file 'no_dots.txt' is:&lt;BR /&gt;
      File Name=C:\Applications\UK.Liquidity2\no_dots.txt,&lt;BR /&gt;
      RECFM=V,LRECL=10000&lt;BR /&gt;
&lt;BR /&gt;
NOTE: 1 record was written to the file 'no_dots.txt'.&lt;BR /&gt;
      The minimum record length was 150.&lt;BR /&gt;
      The maximum record length was 150.&lt;BR /&gt;
NOTE: There were 1 observations read from the data set WORK.TEST_DATA.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
301  data _null_ ;&lt;BR /&gt;
302     infile 'no_dots.txt' lrecl=10000 ;&lt;BR /&gt;
303     input ;&lt;BR /&gt;
304     list ;&lt;BR /&gt;
305  run ;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The infile 'no_dots.txt' is:&lt;BR /&gt;
      File Name=C:\Applications\UK.Liquidity2\no_dots.txt,&lt;BR /&gt;
      RECFM=V,LRECL=10000&lt;BR /&gt;
&lt;BR /&gt;
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;BR /&gt;
1         12|1234|2345678|7652|456781234|456|54678456|145678|03456|2345|12345|9843|12345678|543254|34567889045&lt;BR /&gt;
     101  |02345|234567896789|123456789032|234561234|1233456 150&lt;BR /&gt;
NOTE: 1 record was read from the infile 'no_dots.txt'.&lt;BR /&gt;
      The minimum record length was 150.&lt;BR /&gt;
      The maximum record length was 150.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds[/pre]&lt;BR /&gt;
I applied bold for the step which outputs the data and removes the dots</description>
      <pubDate>Wed, 03 Nov 2010 14:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27500#M5046</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-03T14:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27501#M5047</link>
      <description>Peter, that is great, thank you very much. My only problem now is that the compression removes the ending zeros in the data. Is there a way to prevent that from happening?</description>
      <pubDate>Wed, 03 Nov 2010 14:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27501#M5047</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-03T14:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27502#M5048</link>
      <description>well, &lt;BR /&gt;
that implies your data are already formatted - so, &lt;BR /&gt;
remove that statement&lt;BR /&gt;
 &lt;BR /&gt;
format yVar: best18. ;</description>
      <pubDate>Wed, 03 Nov 2010 15:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27502#M5048</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-03T15:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27503#M5049</link>
      <description>Well, I am importing the data from an excel spreadsheet. I know the actual data, meaning yvar1-yvar24, is numeric. I don't have any statement defining that, they imort that way. Are you saying I should use the format you provided? I've got everything else but this darn decimal point thing. Very frustrating.</description>
      <pubDate>Thu, 04 Nov 2010 14:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27503#M5049</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-04T14:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27504#M5050</link>
      <description>I'm having trouble converting from numeric to character for yvar1-yvar24. I need to keep 3 implied decimal places.&lt;BR /&gt;
&lt;BR /&gt;
For example, if one data point was 0.850 I need to it to be 0850 or another example is 1.250 I'd need it to be 1250, implying 3 decimal places. yvar1-yvar24 are imported (using the import wizard, as numeric) converting to character is required to use compress()?</description>
      <pubDate>Thu, 04 Nov 2010 14:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27504#M5050</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-04T14:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27505#M5051</link>
      <description>easy &lt;BR /&gt;
proc format&lt;BR /&gt;
allows you to define how to present numbers&lt;BR /&gt;
it even allows you to multiply by 1000&lt;BR /&gt;
and by 100 in another format.&lt;BR /&gt;
If you have a consistent requirement to show the yVar1-24 in the same format [pre]proc format ;&lt;BR /&gt;
  picture millis(round)&lt;BR /&gt;
       /* missing */ . = ' '&lt;BR /&gt;
            -9.999 - -0    = '00000'(mult=1000 prefix='-')&lt;BR /&gt;
                 0 - 9.999 = '00000'(mult=1000)&lt;BR /&gt;
        other = [best5.]&lt;BR /&gt;
      ;&lt;BR /&gt;
run ;[/pre]%put testing millis %sysfunc( putn( 100/81, millis )) full precision %sysfunc( putn( 100/81, best16 ))   ;&lt;BR /&gt;
%put testing millis %sysfunc( putn(-100/81, millis )) full precision %sysfunc( putn(-100/81, best16 ))   ;&lt;BR /&gt;
%put testing millis %sysfunc( putn( 1, millis )) full precision %sysfunc( putn( 1, best16 ))   ;&lt;BR /&gt;
%put testing millis %sysfunc( putn(-1, millis )) full precision %sysfunc( putn(-1, best16 ))   ;&lt;BR /&gt;
Use the millis. format like[pre]data _null_ ;&lt;BR /&gt;
  file 'your report.txt' lrecl=10000 ;&lt;BR /&gt;
  set your.data ;&lt;BR /&gt;
  format yVar1 - yVar24 millis. ;&lt;BR /&gt;
  put  yVar1 -yVar24 ;&lt;BR /&gt;
run ;[/pre]</description>
      <pubDate>Thu, 04 Nov 2010 17:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27505#M5051</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-04T17:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27506#M5052</link>
      <description>When trying to use the millis format it tells me it is not found or could not be loaded. I am running SAS 9.1, is this not a part of 9.1?</description>
      <pubDate>Thu, 04 Nov 2010 17:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27506#M5052</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-04T17:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27507#M5053</link>
      <description>that is what the proc format code is for</description>
      <pubDate>Thu, 04 Nov 2010 17:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27507#M5053</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-04T17:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27508#M5054</link>
      <description>I see. You created your own format. Let me play with that and I'll report back. Thanks Peter.</description>
      <pubDate>Thu, 04 Nov 2010 17:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27508#M5054</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-04T17:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27509#M5055</link>
      <description>Peter, that does everything I need except for it drops the leading zeros for the observations that are less than one. I.E.&lt;BR /&gt;
&lt;BR /&gt;
0.250 becomes 250 while I need it to look like 0250. The values greater than one like 1.350 look like 1350 and are perfect. Your format works great for removing the decimal point. I would like to learn all this stuff myself, I just need to keep plugging away to gain the knowledge. Maybe once I figure out this project you can run through that format code with a quick explanation?</description>
      <pubDate>Thu, 04 Nov 2010 17:40:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27509#M5055</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-04T17:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27510#M5056</link>
      <description>Given you are interested in a "formatted value", it appears you will need to run through your SAS variable list using PUTN (rather than PUT as I suggested using the BEST. format) along with the return-value from VFORMAT, in order to get your "numeric" data accurately represented as "character-string" data but with any intervening decimal points removed.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search arguments, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
putn function site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
vformat function site:sas.com</description>
      <pubDate>Thu, 04 Nov 2010 17:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27510#M5056</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-04T17:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27511#M5057</link>
      <description>Scott, I think your level of SAS knowledge is too far above mine to know what you mean without further explanation.</description>
      <pubDate>Thu, 04 Nov 2010 18:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27511#M5057</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-04T18:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27512#M5058</link>
      <description>You've been given several code examples with which to start.  Suggest reviewing the DOC on suggested call functions, come up with a program, come back to the forum for feedback, based on your results thus far.&lt;BR /&gt;
&lt;BR /&gt;
Based on what you've seen so far, sure hope you have some sort of SAS program to work with, right?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 04 Nov 2010 18:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27512#M5058</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-04T18:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27513#M5059</link>
      <description>I've been given several different ways to try this. I get close to having one set the way I want it then I get suggested another way to try it and I am back at square one. I was one step away from getting Peter's code working, the only thing I needed to was to keep leading zeros. You suggested something I'm not familiar with, so I asked for more detail. I have about 20 different sets of code I'm trying to make work for me.</description>
      <pubDate>Thu, 04 Nov 2010 18:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27513#M5059</guid>
      <dc:creator>Aar684</dc:creator>
      <dc:date>2010-11-04T18:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Decimal Points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27514#M5060</link>
      <description>If you notice, Peter.C has an early post which uses "PUT", "VVALUE" and "COMPRESS".....suggest working with that technique to begin with. And have a look at VFORMAT and PUTN functions in the SAS DOC or the SAS-hosted DOC on the support site.&lt;BR /&gt;
&lt;BR /&gt;
I'm more inclined to lead instead of dragging, but there may be others on this forum who will do the coding for you.....by all means.  In the meantime, let's see what you've got and go from there -- again, preferably in a SAS-generated log, not as your program.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.

Message was edited by: sbb</description>
      <pubDate>Thu, 04 Nov 2010 18:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Decimal-Points/m-p/27514#M5060</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-04T18:46:19Z</dc:date>
    </item>
  </channel>
</rss>

