BookmarkSubscribeRSS Feed
tomrvincent
Rhodochrosite | Level 12

Anybody know how to export a 13 digit number to excel without it coming out in scientific notation? 

7 REPLIES 7
ballardw
Super User

How are you currently "exporting" the values.

And have you tried making the column wider in Excel?

tomrvincent
Rhodochrosite | Level 12
I'm trying not to do anything in excel manually (that would be too easy...plus I'm dealing with several dozen monthly files).

I wanted to simply send it as a CSV or text, but the customer is a moron who doesn't know how Excel works.

I just wondered if anyone had a quick fix for this nonsense.
ballardw
Super User

@tomrvincent wrote:
I'm trying not to do anything in excel manually (that would be too easy...plus I'm dealing with several dozen monthly files).

I wanted to simply send it as a CSV or text, but the customer is a moron who doesn't know how Excel works.

I just wondered if anyone had a quick fix for this nonsense.

That is part of why I asked HOW you are exporting the data. The ODS EXCEL supports an option Absolute_column_width. The following example sets all of the columns to a width of 16

 

ods excel file='footer.xlsx'    
          options(absolute_column_width='16');
proc print data=sashelp.class(obs=5);
run;
ods excel close;

Or to set width per column:

 

ods excel file='x:\footer.xlsx'    
          options(absolute_column_width='16,5,8,10,10' );
proc print data=sashelp.class(obs=5);
run;
ods excel close;

ods tagsets.excelxp creates excel readable XML with the same options if you don't have SAS/Access Interface to PC Files

 

tomrvincent
Rhodochrosite | Level 12
I tried using ods excel but it blows out of memory, so I'm just using proc export.
tomrvincent
Rhodochrosite | Level 12
tried it with 5 records and still get scinote in the resulting file. Width had no effect.
ballardw
Super User

@tomrvincent wrote:
tried it with 5 records and still get scinote in the resulting file. Width had no effect.

What is the actual format associated with the variable?

If you use Proc Print as a basic ODS generator then the format applies. If you have a format of best8., or just about anything with a less than 13, or possibly 14, width you'll get some form of truncation or rounding.

data _null_;
  x= 123456781234;
  put  x best8.;
  put x  best11.;

  put x best13.;
run;
tomrvincent
Rhodochrosite | Level 12
I certainly wouldn't use less than 13 with a 13 digit number. That doesn't make any sense at all.

I tried everything I could think of...settled on bestd13.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 2162 views
  • 0 likes
  • 2 in conversation