<?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 keep SAS from automatically converting numbers to scientific notation when concatenating in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395627#M12030</link>
    <description>&lt;P&gt;That's because it's numeric. When you use CATX() it will convert&amp;nbsp;the numbers to characters automatically, but it has to assume a format and it does so incorrectly in this case (and a lot of cases). So you need to explicitly provide the conversion or store them as characters&amp;nbsp;in the first place.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's probably easiest to convert them to character before the transpose and then use CATX to combine with&amp;nbsp;the commas. CATX is smart enough to only include fields that are present.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;combined = catx(", ", of upc1-upc10);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2017 16:43:20 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-09-13T16:43:20Z</dc:date>
    <item>
      <title>How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395614#M12029</link>
      <description>&lt;P&gt;I have an original table with 2 columns: PLU, UPC. The PLU is a coupon and the UPcs are the items the coupon can be redeemed on. I need a table with 1 row for each PLU and the UPCs in their own individual columns, so I've used proc transpose. From there, I created new columns that concatenate each UPC column with a comma so that when I export into excel, I can create a list by concatenating all of the columns together (rather than having to add in a comma myself; it's already extremely cumbersome to begin with and I already have it all set up &amp;amp; ready to go).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is, for SOME UPCs (13 digits or larger), when I concatenate with a comma, SAS automatically puts the UPC number in scientific notation. How can I stop this from happening?&lt;BR /&gt;&lt;BR /&gt;Example:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;PLU&lt;/TD&gt;&lt;TD&gt;col544&lt;/TD&gt;&lt;TD&gt;col545&lt;/TD&gt;&lt;TD&gt;_testcol1_&lt;/TD&gt;&lt;TD&gt;_testcol2_&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;997039&lt;/TD&gt;&lt;TD&gt;942190214800&lt;/TD&gt;&lt;TD&gt;6839533032788&lt;/TD&gt;&lt;TD&gt;,942190214800&lt;/TD&gt;&lt;TD&gt;, 6.839533E12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;997264&lt;/TD&gt;&lt;TD&gt;7290010582877&lt;/TD&gt;&lt;TD&gt;7502257290010&lt;/TD&gt;&lt;TD&gt;,7.2900106E12&lt;/TD&gt;&lt;TD&gt;,7.5022573E12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that the _testcol1_ value for PLU&amp;nbsp;&lt;SPAN&gt;997039 turns out exactly how I want it. The others are converting to scientific notation and I need that to NOT happen.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395614#M12029</guid>
      <dc:creator>AMandak</dc:creator>
      <dc:date>2017-09-13T16:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395627#M12030</link>
      <description>&lt;P&gt;That's because it's numeric. When you use CATX() it will convert&amp;nbsp;the numbers to characters automatically, but it has to assume a format and it does so incorrectly in this case (and a lot of cases). So you need to explicitly provide the conversion or store them as characters&amp;nbsp;in the first place.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's probably easiest to convert them to character before the transpose and then use CATX to combine with&amp;nbsp;the commas. CATX is smart enough to only include fields that are present.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;combined = catx(", ", of upc1-upc10);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395627#M12030</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T16:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395629#M12031</link>
      <description>&lt;P&gt;Thanks! I was JUST about to reply to my own post saying I figured it out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're right, if I convert to a text value first and then concatenate, it keeps the entire number.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395629#M12031</guid>
      <dc:creator>AMandak</dc:creator>
      <dc:date>2017-09-13T16:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395635#M12032</link>
      <description>&lt;P&gt;Note how you can use CATX instaed of adding hte commas manually.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395635#M12032</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T16:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395646#M12033</link>
      <description>Yes I tried that, but I think there are too many columns because it doesn't work for every PLU. I think if there are 20+ UPCs, it just won't concatenate. But I'll remember that for future reference.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For now, I'm using a do loop. It takes a minute but it gives me what I need:&lt;BR /&gt;data redemption_UPCs_v3;&lt;BR /&gt;set redemption_UPCs_v2;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%macro concatenation (howmany);&lt;BR /&gt;%do i=2 %to &amp;amp;howmany;&lt;BR /&gt;data redemption_UPCs_v3;&lt;BR /&gt;set redemption_UPCs_v3;&lt;BR /&gt;if UPC&amp;amp;i. ne '' then col_txt_&amp;amp;i. = (','||UPC&amp;amp;i.);&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend create;&lt;BR /&gt;&lt;BR /&gt;%concatenation(918);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks so much for your help!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395646#M12033</guid>
      <dc:creator>AMandak</dc:creator>
      <dc:date>2017-09-13T17:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395648#M12034</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/164786"&gt;@AMandak&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue is, for SOME UPCs (13 digits or larger), when I concatenate with a comma, SAS automatically puts the UPC number in scientific notation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do not store the UPC codes as numbers! &amp;nbsp;13 digits is very close to the maximum number of digits that SAS floating point numbers can represent exactly.&lt;/P&gt;
&lt;PRE&gt;121   data _null_;
122     x=constant('exactint');
123     put x= comma23. ;
124    run;

x=9,007,199,254,740,992
&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395648#M12034</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-13T17:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395653#M12035</link>
      <description>&lt;P&gt;If you just want to collapse do it directly from the source and skip the PROC TRANPOSE.&lt;/P&gt;
&lt;P&gt;If you have read the raw UBC codes as numbers instead of strings then you might be able to convert it using the Z format to make them all have the same number of characters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  length plu $10 ubcn 8 ; 
  input plu ubcn ;
  ubc = put(ubcn,z13.);
cards;
997039 942190214800
997039 6839533032788
997264 7290010582877
997264 7502257290010
;

data want ;
  do until(last.plu);
    set have ;
    by plu ;
    length ubc_rollup $2000 ;
    ubc_rollup=catx(', ',ubc_rollup,ubc);
  end;
  drop ubcn ubc;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 312px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15098i495EE0A5C71F2A5D/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395653#M12035</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-13T17:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395655#M12036</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/164786"&gt;@AMandak&lt;/a&gt; wrote:&lt;BR /&gt;Yes I tried that, but I think there are too many columns because it doesn't work for every PLU. I think if there are 20+ UPCs, it just won't concatenate. But I'll remember that for future reference.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think that's correct, but I guess as long as you have something that works for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do have to make sure the string is long enough in the first place possibly and may need a loop for conversion depending on when you do that, before or after the transpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
array test(50);
array _t(50) $10.;
length catted_var $3000.;
do i=1 to 50;
    test(i) = floor(rand('uniform')*10000)+1;
    _t(i) = put(test(i), z10.);
end;

catted_var = catx(", ", of _t1-_t50);

run;&lt;/CODE&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:16:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395655#M12036</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T17:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395658#M12037</link>
      <description>&lt;P&gt;To expand on this, the magic number is 15 digits. 16 digit and larger integers cannot be assured of being stored correctly in the 8 byte floating point notation that SAS uses. This will happen without warning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/395658#M12037</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-09-13T17:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/559167#M17115</link>
      <description>&lt;P&gt;Hi Tom&lt;/P&gt;&lt;P&gt;Is there a way to change 8 byte floating point notation that SAS uses?&amp;nbsp; The proc freq stmt totals a number in scientific notation. Is there a way to modify the format output that will remove scientific notation?&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 21:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/559167#M17115</guid>
      <dc:creator>BBarbour</dc:creator>
      <dc:date>2019-05-15T21:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep SAS from automatically converting numbers to scientific notation when concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/559170#M17116</link>
      <description>Not easily. Use PROC TABULATE instead which does allow you to specify the formats easily.</description>
      <pubDate>Wed, 15 May 2019 21:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-keep-SAS-from-automatically-converting-numbers-to/m-p/559170#M17116</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-15T21:19:51Z</dc:date>
    </item>
  </channel>
</rss>

