DATA Step, Macro, Functions and more

Data issue

Reply
Super Contributor
Posts: 270

Data issue

Hi I need help for the following question.

Raw data Variable HOUR values are:

23.67
-22.48
-1.33


My code: VSTPTNUM=HOUR;

Results;

23.666666

-22.4833333

-1.3333333


But the data got from vendor shows results:

23.666666667

-22.48333333

-1.333333333

How did the vendor data shows more digits after decimal than my results. please help in my code. Thank you.

Super User
Posts: 17,750

Re: Data issue

[ Edited ]

I believe this is an issue in numerical precision and how your data is stored within a computer. You can google the term to find many questions and the responses for dealing with this. 

 

I guess my question is what do you want for an output? Also, did you specify informats/formats and you don't show how the vendor recevied/imported the number.  Currently there's too many unknowns to comment beyond the above statement.

Trusted Advisor
Posts: 1,115

Re: Data issue

[ Edited ]

Hi @knveraraju91,

 

All of these numbers are different, both mathematically and for SAS. The latter is shown by the code below:

data test;
input hour;
cards;
23.67
-22.48
-1.33
23.666666
-22.4833333
-1.3333333
23.666666667
-22.48333333
-1.333333333
;

proc sort data=test nodupkey;
by hour;
run;

proc print data=test;
format hour best12.;
run;

So, if the "raw data" were e.g. 23.67 and you obtained 23.666666, then the raw data must have been rounded. Similarly, the vendor's values could be truncated to fewer decimals to match your results.

 

When working with numeric variables in SAS you should always distinguish between

  • the ("true") value stored internally, which is used for calculations, comparisons etc. and
  • the displayed value, which is always a formatted value.

 

What file format are the raw data and how did you import them into SAS?

What file format are the vendor's data?

 

Super User
Posts: 10,466

Re: Data issue

A real crude guess: the original data you looked at was in Excel and set to display 2 decimals even though more were present. And then the data was imported to SAS using Proc import which ignores Excel decimal setting.

Ask a Question
Discussion stats
  • 3 replies
  • 193 views
  • 0 likes
  • 4 in conversation