<?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 this number to character 0.9976452119. Put function is giving me 1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824143#M325436</link>
    <description>&lt;P&gt;Just realized some of my values are converting in a wrong format when&amp;nbsp; I used put(temp1,Best30.)&lt;/P&gt;
&lt;P&gt;Actual value:&lt;/P&gt;
&lt;TABLE width="262"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="262"&gt;2022-06-07 16:02:59.170093000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output value:&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="301"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="301"&gt;1973779822.69097&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so used the following, still not returning the correct values..&lt;/P&gt;
&lt;P&gt;put(temp1, datetime16.)&lt;/P&gt;
&lt;P&gt;How can i read Actual value completely with out changing the format?&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jul 2022 14:34:32 GMT</pubDate>
    <dc:creator>Stalk</dc:creator>
    <dc:date>2022-07-19T14:34:32Z</dc:date>
    <item>
      <title>How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/823602#M325211</link>
      <description>&lt;P&gt;I have a percent field that I need to convert and keep all the decimal points. Following code is converting my&amp;nbsp; value from 0.9976452119 to 1 when I use PUT function. for some fields when I convert from numeric to char it is returning blank values.&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; create table test as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select pid, put(percent_s,30.) as percent_char;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; from test;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions?&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 03:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/823602#M325211</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2022-07-16T03:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/823604#M325213</link>
      <description>&lt;P&gt;That is what a format with zero decimal places is supposed to do.&lt;/P&gt;
&lt;P&gt;You could tell it how many decimal places to use.&lt;/P&gt;
&lt;P&gt;Or you could try the BEST format instead and SAS will decide how many decimal places the value needs.&lt;/P&gt;
&lt;PRE&gt;2758  data _null_;
2759    x=0.9976452119;
2760    put x= / x= 30.20 / x= best30. ;
2761  run;

x=0.9976452119
x=0.99764521190000000000
x=0.9976452119
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You could also use the CATS() function as that will convert a number using something very similar to the BEST32. format.&amp;nbsp; It also has the advantage of removing the leading spaces from the generated string.&amp;nbsp; With the PUT function you might need to use LEFT() function or the -L format modifier to remove the leading spaces from the generated string.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 03:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/823604#M325213</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-16T03:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/823910#M325359</link>
      <description>Used Best30. and it worked.&lt;BR /&gt;Thank you</description>
      <pubDate>Mon, 18 Jul 2022 17:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/823910#M325359</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2022-07-18T17:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824143#M325436</link>
      <description>&lt;P&gt;Just realized some of my values are converting in a wrong format when&amp;nbsp; I used put(temp1,Best30.)&lt;/P&gt;
&lt;P&gt;Actual value:&lt;/P&gt;
&lt;TABLE width="262"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="262"&gt;2022-06-07 16:02:59.170093000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output value:&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="301"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="301"&gt;1973779822.69097&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so used the following, still not returning the correct values..&lt;/P&gt;
&lt;P&gt;put(temp1, datetime16.)&lt;/P&gt;
&lt;P&gt;How can i read Actual value completely with out changing the format?&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 14:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824143#M325436</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2022-07-19T14:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824148#M325440</link>
      <description>&lt;P&gt;BEST does not change the value, just how to display it as characters.&lt;/P&gt;
&lt;P&gt;Since SAS stores datetime values as number of seconds since 1960 the value for the datetime you mention about 1,970,236,979.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;5    data _null_;
6     dt = '07JUN2022:16:02:59.170093000'dt;
7     put dt best30. ;
8    run;

              1970236979.17009
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you actually got a value of&amp;nbsp;1,973,779,822 then you are over a month off.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    data _null_;
2     dt = 1973779822.69097 ;
3     put dt datetime26.5 ;
4    run;

  18JUL2022:16:10:22.69097
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 14:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824148#M325440</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-19T14:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824209#M325465</link>
      <description>&lt;P&gt;Thank you Tom.&lt;/P&gt;
&lt;P&gt;datetime26. worked but I need the output in the following format&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2022-07-18 16:10:22.690972090&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOT&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;18JUL2022&lt;/STRONG&gt;:16:10:22.690972090&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any simple way?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 18:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824209#M325465</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2022-07-19T18:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824216#M325469</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/358432"&gt;@Stalk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you Tom.&lt;/P&gt;
&lt;P&gt;datetime26. worked but I need the output in the following format&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2022-07-18 16:10:22.690972090&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOT&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;18JUL2022&lt;/STRONG&gt;:16:10:22.690972090&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any simple way?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't think there is an existing format that displays datetime values in the way.&amp;nbsp; You could look at trying to create one using the PICTURE statement of PROC FORMAT.&lt;/P&gt;
&lt;P&gt;Or build the string in pieces, but note that you cannot store that many decimal places on a number that large.&amp;nbsp; SAS can only represent about 15 decimal digits exactly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 dt = '18JUL2022:16:10:22.690972090'dt;
 string=put(datepart(dt),yymmdd10.)||' '||put(int(dt),tod8.)||put(mod(dt,1),10.9);
 put dt datetime26.5 / string ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;25   data _null_;
26    dt = '18JUL2022:16:10:22.690972090'dt;
27    string=put(datepart(dt),yymmdd10.)||' '||put(int(dt),tod8.)||put(mod(dt,1),10.9);
28    put dt datetime26.5 / string ;
29   run;

  18JUL2022:16:10:22.69097
2022-07-18 16:10:22.691000000
&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2022 18:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824216#M325469</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-19T18:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824246#M325493</link>
      <description>&lt;P&gt;I am reading from one database and writing to another database so I cannot change a single digit or format in my conversion.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 21:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824246#M325493</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2022-07-19T21:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824257#M325501</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/358432"&gt;@Stalk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am reading from one database and writing to another database so I cannot change a single digit or format in my conversion.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are using SAS to read or write from an external database then there should be no need to re-format the values at all.&amp;nbsp; If the variable is DATETIME in the external database then the SAS/Access engine for that type of data will transfer the values to a SAS datetime value.&amp;nbsp; And the reverse.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 22:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824257#M325501</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-19T22:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824266#M325506</link>
      <description>&lt;P&gt;I am using ODBC connection to read from external DB and writing to Excel templates. have 15 fields. Most of them are string fields, two fields are double and one field is timestamp.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname HD odbc dsn='HD_V';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Hadoop_table;&lt;BR /&gt;set HD.RPM ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I keep the original format for the three non-string fields? especially the timestamp field where SAS is rounding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 00:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824266#M325506</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2022-07-20T00:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert this number to character 0.9976452119. Put function is giving me 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824439#M325603</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Heard that SAS/Access to Hadoop only work on&amp;nbsp;9.4M7. I have 9.4M3. So I need to work around to read the data with out changing the data\formats&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 18:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-this-number-to-character-0-9976452119-Put/m-p/824439#M325603</guid>
      <dc:creator>Stalk</dc:creator>
      <dc:date>2022-07-20T18:29:37Z</dc:date>
    </item>
  </channel>
</rss>

