<?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: How to convert percents to real number? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888505#M39461</link>
    <description>The best I could get by "Format GrossReturn 10.5;" is five decimals, but this is not good enough for me. I need to get all 16 decimals. Is it possible at all?</description>
    <pubDate>Wed, 09 Aug 2023 06:28:00 GMT</pubDate>
    <dc:creator>IgorR</dc:creator>
    <dc:date>2023-08-09T06:28:00Z</dc:date>
    <item>
      <title>How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888378#M39448</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My question has two parts:&lt;/P&gt;&lt;P&gt;1. I import data from excel and it comes to SAS in this format:&lt;/P&gt;&lt;PRE&gt;2008 | 1 | (18.13%) | (19.3%)
2009 | 1 |  25.50%  |  23.8%
2010 | 1 |   8.55%  |   7.0%
2011 | 1 | ( 6.42%) | ( 7.7%)&lt;/PRE&gt;&lt;P&gt;I need to convert the percents to real numbers format so it will look like this (precision does important!!!):&lt;/P&gt;&lt;PRE&gt;2008 | 1 | -0.1812793769191860| -0.1925832119518600
2009 | 1 |  0.2550005600450760|  0.2376731361391290
2010 | 1 |  0.0854571645604569|  0.0704705764896025
2011 | 1 | -0.0641682597261736| -0.0770890135366603&lt;/PRE&gt;&lt;P&gt;The Question - How to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I will glad to get all real numbers formats i can use in format statement. I can't find them in net.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888378#M39448</guid>
      <dc:creator>IgorR</dc:creator>
      <dc:date>2023-08-08T14:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888389#M39450</link>
      <description>For the current variables in SAS, what is the type and format assigned?</description>
      <pubDate>Tue, 08 Aug 2023 14:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888389#M39450</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-08-08T14:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888404#M39452</link>
      <description>&lt;P&gt;I seriously doubt that SAS placed any pipe characters between values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How did you import those values?&lt;/P&gt;
&lt;P&gt;Run Proc Contents on the data set and show us the result with the variable names, column positions, formats and informats.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 15:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888404#M39452</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-08T15:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888422#M39453</link>
      <description>&lt;P&gt;If you don't want the values to print like percents the REMOVE the attached format.&lt;/P&gt;
&lt;P&gt;You don't say what the variables are named, let's call them PERCENT1 and PERCENT2.&lt;/P&gt;
&lt;P&gt;So let's try to re-create your dataset from your "listing" of the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards dlm='|';
  input year x percent1 percent2 ;
  format percent1 percent2 percent9.2;
cards;
2008 | 1 | -0.1812793769191860| -0.1925832119518600
2009 | 1 |  0.2550005600450760|  0.2376731361391290
2010 | 1 |  0.0854571645604569|  0.0704705764896025
2011 | 1 | -0.0641682597261736| -0.0770890135366603
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now it we just print it the result will look like:&lt;/P&gt;
&lt;PRE&gt;Obs    year    x     percent1     percent2

 1     2008    1    ( 18.13%)    ( 19.26%)
 2     2009    1      25.50%       23.77%
 3     2010    1       8.55%        7.05%
 4     2011    1    (  6.42%)    (  7.71%)
&lt;/PRE&gt;
&lt;P&gt;But if we print it WITHOUT the PERCENT format attached the variables&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have;
  format percent1 percent2 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then we get:&lt;/P&gt;
&lt;PRE&gt;Obs    year    x    percent1    percent2

 1     2008    1    -0.18128    -0.19258
 2     2009    1     0.25500     0.23767
 3     2010    1     0.08546     0.07047
 4     2011    1    -0.06417    -0.07709
&lt;/PRE&gt;
&lt;P&gt;because by default SAS will use the BEST12 format to display numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to see more decimal places then use a different display format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 16:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888422#M39453</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-08T16:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888501#M39458</link>
      <description>&lt;P&gt;The proc content results:&lt;/P&gt;&lt;PRE&gt;The CONTENTS Procedure

Data Set Name : WORK.NET_YIELDS 
Observations : 40 
Member Type : DATA 
Variables : 4 
Engine : V9 
Indexes : 0 
Created : 08/09/2023 08:18:55 
Observation Length : 32 
Last Modified : 08/09/2023 08:18:55 
Deleted Observations : 0 
Protection : 
Compressed : NO 
Data Set Type :
Sorted : NO 
Label :   
Data Representation : WINDOWS_64 
Encoding : whebrew Hebrew (Windows) 

Engine/Host Dependent Information

Data Set Page Size : 65536 
Number of Data Set Pages : 1 
First Data Page : 1 
Max Obs per Page : 2039 
Obs in First Data Page : 40 
Number of Data Set Repairs : 0 
ExtendObsCounter : YES 
Filename : \net_yields.sas7bdat 
Release Created : 9.0401M7 
Host Created : 
Owner Name :  
File Size : 128KB 
File Size (bytes) : 131072 

Alphabetic List of Variables and Attributes
# Variable        Type  Len  Format   Label
1 CalYear         Num  8      BEST.    Cal year 
3 GrossReturn Num  8      10.4       Gross return 
2 Historic          Num 8       BEST.    Historic? 
4 NetReturn     Num  8      10.4       Net return &lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2023 05:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888501#M39458</guid>
      <dc:creator>IgorR</dc:creator>
      <dc:date>2023-08-09T05:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888502#M39459</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I use this code to import the data from excel file. The file is not belong to me, so I can't change the data appearance within the file:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Proc Import Out = Net_Yields
Datafile = "\File.xlsx"
dbms = xlsx
replace;
Getnames = YES;
Sheet = "Gtee Vector";
Range = "S5:V45";
Run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code return the values as percent.&lt;/P&gt;&lt;P&gt;But to perform calculations on the values I need them to be in format of real numbers with all decimals. It's very important because i work with very large numbers and every decimal make sense.&lt;/P&gt;&lt;P&gt;So I need format that will keep the whole data.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 05:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888502#M39459</guid>
      <dc:creator>IgorR</dc:creator>
      <dc:date>2023-08-09T05:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888503#M39460</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446395"&gt;@IgorR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I use this code to import the data from excel file. The file is not belong to me, so I can't change the data appearance within the file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;Proc Import Out = Net_Yields
Datafile = "\File.xlsx"
dbms = xlsx
replace;
Getnames = YES;
Sheet = "Gtee Vector";
Range = "S5:V45";
Run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code return the values as percent.&lt;/P&gt;
&lt;P&gt;But to perform calculations on the values I need them to be in format of real numbers with all decimals. It's very important because i work with very large numbers and every decimal make sense.&lt;/P&gt;
&lt;P&gt;So I need format that will keep the whole data.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you are doing something else. If this is from that Work.Net_yields shown in proc contents then none of the variables would show a % anywhere. BEST formats will fit the number of digits displayed into the length, 10.4 will display the numeric value with 4 decimal places. &lt;/P&gt;
&lt;PRE&gt;# Variable        Type  Len  Format   Label
1 CalYear         Num  8      BEST.    Cal year 
3 GrossReturn Num  8      10.4       Gross return 
2 Historic          Num 8       BEST.    Historic? 
4 NetReturn     Num  8      10.4       Net return &lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2023 05:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888503#M39460</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-09T05:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888505#M39461</link>
      <description>The best I could get by "Format GrossReturn 10.5;" is five decimals, but this is not good enough for me. I need to get all 16 decimals. Is it possible at all?</description>
      <pubDate>Wed, 09 Aug 2023 06:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888505#M39461</guid>
      <dc:creator>IgorR</dc:creator>
      <dc:date>2023-08-09T06:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888507#M39463</link>
      <description>You will need to compromise a little if using base SAS software. SAS does not guarantee numeric precision beyond 15 significant digits.&lt;BR /&gt;&lt;BR /&gt;Try applying the format 18.15.  The width of 18 allows for a negative sign and a decimal point.</description>
      <pubDate>Wed, 09 Aug 2023 06:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888507#M39463</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-08-09T06:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888509#M39464</link>
      <description>&lt;P&gt;This PROC CONTENTS output is&amp;nbsp;&lt;U&gt;very clearly&lt;/U&gt; not from the dataset in your initial post. Variable names and/or labels are different.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 07:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888509#M39464</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-08-09T07:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert percents to real number?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888518#M39465</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446395"&gt;@IgorR&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446395"&gt;@IgorR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But to perform calculations on the values I need them to be in format of real numbers with all decimals. It's very important because i work with very large numbers and every decimal make sense.&lt;/P&gt;
&lt;P&gt;So I need format that will keep the whole data.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note that a SAS format does &lt;EM&gt;not&lt;/EM&gt; change the value of a variable. So, if the calculations are performed &lt;EM&gt;in SAS&lt;/EM&gt;, you can be sure that all decimals (more precisely: all &lt;EM&gt;binary&lt;/EM&gt; digits of the internal representation) are used, regardless of the format attached or used for display.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example (log) using one of the values from your initial post:&lt;/P&gt;
&lt;PRE&gt;130   data _null_;
131   p=0.0854571645604569;
132   put (4*p)(best16. / best20.-l / +1 e21. / binary64.);
133   run;

0.08545716456046
0.08545716456045
  8.54571645604570E-02
0011111110110101111000001000010101001110111111101111110101001110
&lt;/PRE&gt;
&lt;P&gt;As you can see, in this case the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p0ft9ab99s98msn1vblkk4c5bd3l.htm" target="_blank" rel="noopener"&gt;E21. format&lt;/A&gt; reveals one additional decimal and shows that &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p1fum54c93f8r0n1wrs5mrb05nzi.htm" target="_blank" rel="noopener"&gt;BEST16.&lt;/A&gt;, unlike BEST20., rounded the previous decimal correctly. Yet, the "...70" is still rounded, compared to the original numeric literal in the assignment statement. A conversion of the binary digits of the internal binary representation (shown by the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p1b6ugw71lmhnpn1wixijtysezzg.htm" target="_blank" rel="noopener"&gt;BINARY64. format&lt;/A&gt;) results in&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;0.085457164560456&lt;FONT color="#339966"&gt;90&lt;/FONT&gt;&lt;/STRONG&gt;52334653633806738071143627166748046875&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;confirming that also the last decimal (9) of the original value is present internally. Better still, the conversion of internal binary representations modified in the least significant bit (-/+ 1) shows that the internal accuracy goes slightly beyond that last decimal:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;0.085457164560456&lt;FONT color="#339966"&gt;89&lt;/FONT&gt;&lt;/STRONG&gt;135567755556621705181896686553955078125
&lt;STRONG&gt;0.085457164560456&lt;FONT color="#339966"&gt;90&lt;/FONT&gt;&lt;/STRONG&gt;52334653633806738071143627166748046875
&lt;STRONG&gt;0.085457164560456&lt;FONT color="#339966"&gt;91&lt;/FONT&gt;&lt;/STRONG&gt;911125317119513056240975856781005859375
&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2023 08:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-percents-to-real-number/m-p/888518#M39465</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-08-09T08:35:32Z</dc:date>
    </item>
  </channel>
</rss>

