<?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: Import value with 10 decimal places in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790864#M253237</link>
    <description>&lt;P&gt;As long as your string has all decimals, the number will also have it, until you run into the limits of numeric precision:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
string = "0.001620588";
num = input(string,best32.);
format num 23.20;
put num=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 69         data _null_;
 70         string = "0.001620588";
 71         num = input(string,best32.);
 72         format num 23.20;
 73         put num=;
 74         run;
 
 num=0.00162058800000000000&lt;/PRE&gt;
&lt;P&gt;Numeric precision comes into play in this example:&lt;/P&gt;
&lt;PRE&gt; 69         data _null_;
 70         string = "0.12345678901234567890";
 71         num = input(string,best32.);
 72         format num 23.20;
 73         put num=;
 74         run;
 
 num=0.12345678901234000000&lt;/PRE&gt;
&lt;P&gt;So you must inspect your character values created by PROC IMPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For further help, post example data as a data step with datalines, and/or attach the Excel file so we can show you the proper way to import the data through a csv file.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jan 2022 12:23:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-01-19T12:23:18Z</dc:date>
    <item>
      <title>Import value with 10 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790823#M253221</link>
      <description>&lt;P&gt;I'm trying to Import value from Excel (.xls) to create the SAS dataset. I see that after Import, value is getting rounded which I dont want.&lt;/P&gt;
&lt;P&gt;Value in Excel is 0,001620588 and after Import I need the same value 0.001620588 in SAS dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the following step in data step but the value is rounded to 0.00162059&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(input(A,Best32.)) as Value length = 8.&lt;/PRE&gt;
&lt;P&gt;Even I tried with the Format 15.12 but still it's not producing the desired result. Any help?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 08:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790823#M253221</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2022-01-19T08:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Import value with 10 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790827#M253224</link>
      <description>&lt;P&gt;Your code is &lt;U&gt;&lt;STRONG&gt;NOT&lt;/STRONG&gt;&lt;/U&gt; valid data step code, it looks like SQL.&lt;/P&gt;
&lt;P&gt;You must first and foremost question yourself why you have a character variable after import when it should be numeric. This is most likely a result of the guessing of PROC IMPORT, caused by the use of the &amp;lt;add a list of expletives here&amp;gt; Excel file format for data transfer.&lt;/P&gt;
&lt;P&gt;Once again, my advice is to save the spreadsheet to a csv file and read that with a data step you write yourself, taking care of proper variable typing, and where you can use a custom informat to deal with any special values that caused IMPORT to read the variable as character.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 08:36:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790827#M253224</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-19T08:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Import value with 10 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790830#M253226</link>
      <description>Let me simplify my question. Which format to use in INPUT function to&lt;BR /&gt;generate the value with 10 digits after decimal point?&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Jan 2022 08:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790830#M253226</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2022-01-19T08:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Import value with 10 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790864#M253237</link>
      <description>&lt;P&gt;As long as your string has all decimals, the number will also have it, until you run into the limits of numeric precision:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
string = "0.001620588";
num = input(string,best32.);
format num 23.20;
put num=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 69         data _null_;
 70         string = "0.001620588";
 71         num = input(string,best32.);
 72         format num 23.20;
 73         put num=;
 74         run;
 
 num=0.00162058800000000000&lt;/PRE&gt;
&lt;P&gt;Numeric precision comes into play in this example:&lt;/P&gt;
&lt;PRE&gt; 69         data _null_;
 70         string = "0.12345678901234567890";
 71         num = input(string,best32.);
 72         format num 23.20;
 73         put num=;
 74         run;
 
 num=0.12345678901234000000&lt;/PRE&gt;
&lt;P&gt;So you must inspect your character values created by PROC IMPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For further help, post example data as a data step with datalines, and/or attach the Excel file so we can show you the proper way to import the data through a csv file.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 12:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790864#M253237</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-19T12:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Import value with 10 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790928#M253265</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Let me simplify my question. Which format to use in INPUT function to&lt;BR /&gt;generate the value with 10 digits after decimal point?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Basically "10 digits after decimal" has little to do with the INPUT and more to do with the assigned format.&lt;/P&gt;
&lt;P&gt;You have to display at least 12 characters, the leading 0, the decimal and then the desired digits.&lt;/P&gt;
&lt;PRE&gt;data example;
   x=0.12345678910234;
   put "Format: best5 " x= best5.;
   put "Format: best6 " x= best6.;
   put "Format: best7 " x= best7.;
   put "Format: best8 " x= best8.;
   put "Format: best9 " x= best9.;
   put "Format: best10" x= best10.;
   put "Format: best11" x= best11.;
   put "Format: best12" x= best12.;
   put "Format: best13" x= best13.;
   put "Format: f10.  " x= f10.;
   put "Format: f12.10" x= f12.10;
run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jan 2022 15:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790928#M253265</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-19T15:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Import value with 10 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790937#M253267</link>
      <description>&lt;P&gt;Does the value in EXCEL actually have a comma as the decimal point instead of period? Or was that a typo in your question?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS stores numbers as floating point values, so within the limits of the precision of storing decimal fractions using binary floating point values the numbers should match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to change the way the floating number is displayed then adjust the FORMAT you use to DISPLAY the number as a text string.&amp;nbsp; &amp;nbsp;If you don't attach a format then most places SAS will use BEST12. format to display the value. Although I believe that PROC SQL select will use BEST8. instead.&lt;/P&gt;
&lt;PRE&gt;361   data _null_;
362     x=0.001620588;
363     put x= best12. / x=best8. / x=12.10 ;
364   run;

x=0.001620588
x=0.001621
x=0.0016205880
&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jan 2022 16:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790937#M253267</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-19T16:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Import value with 10 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790943#M253269</link>
      <description>Excel have a COMMA as a decimal point.&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Jan 2022 16:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790943#M253269</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2022-01-19T16:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Import value with 10 decimal places</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790950#M253273</link>
      <description>&lt;P&gt;So if the column has numbers in it Excel why are you using INPUT()?&amp;nbsp; INPUT() requires a character string as input, not a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the column in Excel have mixed cell types?&amp;nbsp; That would cause SAS to create the variable as character instead of numeric.&amp;nbsp; If you remove the cells that have character strings from the column in the Excel file then SAS will convert the column into a numeric variable.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 16:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-value-with-10-decimal-places/m-p/790950#M253273</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-19T16:38:44Z</dc:date>
    </item>
  </channel>
</rss>

