BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

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.

3 REPLIES 3
Reeza
Super User

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.

FreelanceReinh
Jade | Level 19

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?

 

ballardw
Super User

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.

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