<?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: numeric values convert to exponential value if there is a short numeric format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777433#M247332</link>
    <description>The original values should be displayed.&lt;BR /&gt;For eg. if the numeric column length is 8 and the format is 5. and the value is -24671, I want SAS to show the original values -24671 instead of -24E3.</description>
    <pubDate>Fri, 29 Oct 2021 23:58:34 GMT</pubDate>
    <dc:creator>Mohan_Rang</dc:creator>
    <dc:date>2021-10-29T23:58:34Z</dc:date>
    <item>
      <title>numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777430#M247329</link>
      <description>&lt;P&gt;Hi SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem with numeric values getting converted into exponential format automatically when length of the values in a numeric column exceed the format length. This happens when I use the code shown below - I'm trying to export a SAS huge dataset directly into a CSV file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there any generic options for the PUT statement in the data step shown below which can prevent the numeric values from converting to exponential values. I don't want to use explicit format(put function) for the numeric variable in the data step. Please provide your suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set dsn;&lt;/P&gt;&lt;P&gt;file "/staging/csv/test.csv" dlm=',' dsd lrecl =32000;&lt;/P&gt;&lt;P&gt;put (_all_) (+0);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 23:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777430#M247329</guid>
      <dc:creator>Mohan_Rang</dc:creator>
      <dc:date>2021-10-29T23:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777432#M247331</link>
      <description>What do you want to happen if the number is too big to display in the sort length then?</description>
      <pubDate>Fri, 29 Oct 2021 23:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777432#M247331</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-29T23:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777433#M247332</link>
      <description>The original values should be displayed.&lt;BR /&gt;For eg. if the numeric column length is 8 and the format is 5. and the value is -24671, I want SAS to show the original values -24671 instead of -24E3.</description>
      <pubDate>Fri, 29 Oct 2021 23:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777433#M247332</guid>
      <dc:creator>Mohan_Rang</dc:creator>
      <dc:date>2021-10-29T23:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777434#M247333</link>
      <description>The - sign takes up a position (as do decimals and percentages (2)) so you don't have 5 slots there for the 5 digits plus the minus sign, that would require 6. So how would you like to handle that?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 30 Oct 2021 00:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777434#M247333</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-30T00:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777436#M247335</link>
      <description>I know a format put(col,6.) on the numeric column would resolve this issue. I’m looking for options in the PUT statement in the data _null_ step below or any other generic solution in the data step.&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;set dsn;&lt;BR /&gt;file "/staging/csv/test.csv" dlm=',' dsd lrecl =32000;&lt;BR /&gt;put (_all_) (+0);&lt;BR /&gt;run;</description>
      <pubDate>Sat, 30 Oct 2021 00:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777436#M247335</guid>
      <dc:creator>Mohan_Rang</dc:creator>
      <dc:date>2021-10-30T00:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777442#M247337</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121974"&gt;@Mohan_Rang&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I know a format put(col,6.) on the numeric column would resolve this issue. I’m looking for options in the PUT statement in the data _null_ step below or any other generic solution in the data step.&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The length of a numerical variable defines the bytes used for storing a number. A length of 8 can store a number with up-to 15 digits with full precision so the length doesn't tell you how "big" the numbers are.&lt;/P&gt;
&lt;P&gt;The FORMAT defines how numbers get written. If the format applied to a numerical variable is too short to print the number then scientific notation will get used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a format statement to change the formats for variables in case they are too short. If you need to change the formats for a whole list of vars like for all vars with a name starting with col... then you can also use a wildcard as done in below code for var1 and var2.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  format var1 best6.;
  var1=10000000000;
  var2=var1;
run;

data _null_;
  file print;
  set have;
  format var: 32.;
  put (_all_) (+0);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Oct 2021 01:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777442#M247337</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-10-30T01:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777449#M247344</link>
      <description>This might affect the other decimal values or date values. Is there any logic that we can write that if exponential values are found then format them to original values?</description>
      <pubDate>Sat, 30 Oct 2021 02:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777449#M247344</guid>
      <dc:creator>Mohan_Rang</dc:creator>
      <dc:date>2021-10-30T02:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777452#M247346</link>
      <description>&lt;P&gt;Are you asking how to tell if the format attached to a variable is too short for the values stored in the variable?&lt;/P&gt;
&lt;P&gt;Why not just create the dataset with proper formats attached before trying to write it to text?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to remove or override the formats attached before writing the text file but also keep the formats that are actually NEEDED then check out the FMTINFO() function.&amp;nbsp; You can use the CAT info to let you know which variables have DATE, TIME or DATETIME type formats attached to them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn;
  length id $8 amount date 8;
  format amount 5. date date9.;
  input id amount date :date.;
cards;
1 123456 01JAN2021
;

proc contents data=dsn noprint out=contents; 
run;

proc sql noprint;
%let formats=;
select
   case when fmtinfo(format,'cat') in ('date','time','datetime') then 
   catx(' ',nliteral(name),cats(format,formatl,'.',case when formatd then cats(formatd) else ' ' end))
   else ' ' end
  into :formats separated by ' '
from contents
where format ne ' ' or formatl &amp;gt; 0 
;
quit;

data _null_;
  set dsn;
  format  _numeric_ best32. &amp;amp;formats;
  file log dsd;
  put (_all_) (+0);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;179   data _null_;
180     set dsn;
181     format  _numeric_ best32. &amp;amp;formats;
182     format &amp;amp;formats;
183     file log dsd;
184     put (_all_) (+0);
185   run;

1,123456,01JAN2021
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Oct 2021 02:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777452#M247346</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-30T02:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777464#M247352</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Is there any logic that we can write that if exponential values are found&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Not too sure what you are after tbh, but this test can be done using the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p06uh7sqlh94nxn1gezyms3e9njn.htm" target="_self"&gt;vvalue&lt;/A&gt;() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if index(vvalue(VAR),'E') then ...&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Oct 2021 06:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777464#M247352</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-10-30T06:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777697#M247457</link>
      <description>Thanks for the example. I will try this out.</description>
      <pubDate>Mon, 01 Nov 2021 15:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777697#M247457</guid>
      <dc:creator>Mohan_Rang</dc:creator>
      <dc:date>2021-11-01T15:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: numeric values convert to exponential value if there is a short numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777698#M247458</link>
      <description>Thank you. Yes, this might work too. I have to try this out.</description>
      <pubDate>Mon, 01 Nov 2021 15:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-values-convert-to-exponential-value-if-there-is-a-short/m-p/777698#M247458</guid>
      <dc:creator>Mohan_Rang</dc:creator>
      <dc:date>2021-11-01T15:12:18Z</dc:date>
    </item>
  </channel>
</rss>

