<?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: Round all numeric values in dataset to 3 decimal places in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298553#M62807</link>
    <description>&lt;P&gt;If you want to actually round the values that are stored, you can use array logic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array _nums {*} _numeric_;
do i = 1 to dim(_nums);
  _nums{i} = round(_nums{i},.001);
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2016 08:38:09 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-09-15T08:38:09Z</dc:date>
    <item>
      <title>Round all numeric values in dataset to 3 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298535#M62805</link>
      <description>&lt;P&gt;Title seems straight forward. &amp;nbsp;I'd like to round every number in a dataset to 3 decimal places, to make reading easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd prefer a generic approach, as I don't have variable names beforehand (using output from Proc Means, autoname).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, a related side question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following generic format attempt doesn't work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
format _num_ 9.3;
set have;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS wants the specific variable name, not the generic _num_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 07:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298535#M62805</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-09-15T07:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Round all numeric values in dataset to 3 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298537#M62806</link>
      <description>&lt;P&gt;hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change your FORMAT statement like so&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;&lt;BR /&gt;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;format _numeric_ 9.3;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please note this does not round values, it just changes how the value ist displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you actually want to round the values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 07:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298537#M62806</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2016-09-15T07:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Round all numeric values in dataset to 3 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298553#M62807</link>
      <description>&lt;P&gt;If you want to actually round the values that are stored, you can use array logic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array _nums {*} _numeric_;
do i = 1 to dim(_nums);
  _nums{i} = round(_nums{i},.001);
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 08:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298553#M62807</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-15T08:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Round all numeric values in dataset to 3 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298558#M62808</link>
      <description>&lt;P&gt;AS&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32"&gt;@BrunoMueller﻿&lt;/a&gt;&amp;nbsp;has said, format does not change the underlying value, only how it is displayed. &amp;nbsp;To round a value you would use round(), floor(), ceil() functions. &amp;nbsp;You can do this based on an array if you like:&lt;/P&gt;
&lt;PRE&gt;data have;
  input value1 value2;
  array tmp _numeric_;
  do over tmp;
    tmp=round(tmp,0.001);
  end;
datalines;
1.2354 34.45
23.65788 67.23456
21.34 21.34
;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Sep 2016 08:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298558#M62808</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-15T08:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Round all numeric values in dataset to 3 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298583#M62812</link>
      <description>&lt;P&gt;Things wrong with your code&lt;/P&gt;
&lt;P&gt;1. _num_ instead of _numeric_&lt;/P&gt;
&lt;P&gt;2. Format before SET&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 09:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298583#M62812</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-15T09:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Round all numeric values in dataset to 3 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298852#M62905</link>
      <description>&lt;P&gt;Nice going Kurt. &amp;nbsp;And thanks for helping RW9, Reeza and Bruno.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mission accomplished!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(at least for today....)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 04:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Round-all-numeric-values-in-dataset-to-3-decimal-places/m-p/298852#M62905</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-09-16T04:21:26Z</dc:date>
    </item>
  </channel>
</rss>

