Learning SAS? Welcome to the exclusive online community for all SAS learners.

Dealing with Scientific Notation

Reply
New Contributor
Posts: 4

Dealing with Scientific Notation

Hello,

I directly import xls files into SAS. One in particular contains three columns, two of which contain numerous results in the format or 0.000005. SAS is using scientific notation to represent 0.000005 as 5E-6 and others such as 0.000003 as 3E-6. I have tried using the following

proc print data=file;

format x 7.;

run;

This is not working. Can anybody help me please? Thank you for your time.

Aoife

Super User
Posts: 10,500

Re: Dealing with Scientific Notation

What are the ranges of your numbers? You need to specify a format that will allow sufficient print positions for the smallest number you hope to print. E-6 means decimals so 7. doesn't do much as it says 7 positions of the integer persuasion.

I'd try format 12.8 as a start.

New Contributor
Posts: 4

Re: Dealing with Scientific Notation

Thank you for your reply. What an error. Although having tried format 12.8 and 12.9 the problem remains. The range is from 0 to 0.101879.

Super User
Posts: 10,500

Re: Dealing with Scientific Notation

Can you post the results of Proc Contents for the data set?

Or post some example lines of your output with x formatted as 12.9?

New Contributor
Posts: 4

Re: Dealing with Scientific Notation

Okay so after my proc import statement;

proc import DATAFILE= 'file.xls'

DBMS = xls

out=proborig

replace;

run;

Then I have;

proc print data=proborig;

format x 12.9;

run;

and an example of some data lines as a result of this are;

406118900.000043
40711900.000490.00049
40811910.0013220.002643
409119200.00081
41011945E-60.000011
41111950.0002560.000256
41211960.0002770.000277

The columns are observation, animal, ancestor and founder respectively.

Thanks again for the help

Super User
Posts: 10,500

Re: Dealing with Scientific Notation

Proc contents on the data set.

New Contributor
Posts: 4

Re: Dealing with Scientific Notation

I reassigned the variables to BEST32. with the following code;

data proborig1;

set proborig;

newAnimal = input(Animal, BEST32.);

drop Animal;

rename newAnimal=Animal;

run;

The results of the proc content are;

2AncestorNum8
1AnimalNum8
3FounderNum8


Super User
Posts: 9,681

Re: Dealing with Scientific Notation

Best32.   ?

Regular Contributor
Posts: 184

Re: Dealing with Scientific Notation

xia keshan wrote:

Best32.   ?

Yeah. It doesn't really make sense as an informat, but it's accepted as an alias for 32.

Super User
Super User
Posts: 6,500

Re: Dealing with Scientific Notation

That is just how the "BEST" format works.  Apparently it has decided that using scientific notation is the best way to display numbers that small.

Ask a Question
Discussion stats
  • 9 replies
  • 6528 views
  • 3 likes
  • 5 in conversation