BookmarkSubscribeRSS Feed
Explore_SAS9
Calcite | Level 5

Below code is auto converting value 9d10 to 9e10.It is an account id column loaded into sas from TD.In TD the value is 9d10 whereas in SAS 9E100.

 

data test;

x=9d10;

run;

 

In test dataset the value of x is shown as 9e10.Anybody has any thoughts on why this happens?

 

Thanks in advance!

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

The reason is that the variable X, for which you supply no information, is being created as length 8 numeric variable.  Now 9d10 can be a number and can be represented as 9e10, or 9 to 10 places.  You have not said what you want the variable to be?  Maybe character (even if not, it is always good to state what type and length your varaibles are):

data test;
  length x $20;
  x="9d10";
run;
Explore_SAS9
Calcite | Level 5

Actually the data for account id is wrong in the source file itself.It should be a numeric value but is coming as a character.

 

More on teh background:

An XML file line is fed into a column in teradata table(used as source to SAS dataset).

In SAS that column is parsed using a macro and ACOOUNT value in xml is assigned to numeric variable ACCOUNT.

But the xml data 9d100 in TD is converted to 9e100 in sas and we are having question on why the difference in value.

 

My question is what is the logic behind 9d100 being converted to 9e100 as we need to explain why the value is difefrent.

ACCOUNT column cannot be converted to character as it is inherently numeric.When there is a invalid value it should be same in Teradata and source ideally.

Kurt_Bremser
Super User

Use the notdigit() function on a substring to determine if it's truly numeric before converting.

 

The .D... notation is mentioned in the 9.2 documentation for the Ew.d informat (which is just an alias for w.d in 9.4) as a valid numeric notation.

Tom
Super User Tom
Super User

I do not understand your question. The numbers 9e100 and 9d100 are the same number. They both mean 9 times 10 raised to the 100th power.  In the old days of Fortran they used the D instead of the E to mean to use double precision (8 byte) floating point instead of single precision (4 bytes).  But in SAS all numbers are stored in 8 byte floating point.

 

If the field is an ACCOUNT number then you should probably be treating it as a character string in SAS. You will never need to take the mean of an ACCOUNT number.  Also there is a limit to the number of digits that an 8 byte floating point number can represent exactly.

 

1     data _null_;
2       x=constant('exactint');
3       put x comma24. ;
4     run;

   9,007,199,254,740,992

 

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
  • 5 replies
  • 730 views
  • 0 likes
  • 4 in conversation