@libokj wrote:
Thank you! Precision was indeed the problem. I'm new to SAS and quite unfamiliar with its data structures and features. Specifying length in the data step for edate and ddate before the rewrite solved the problem.
A lot of uses are confused by LENGTH. The conflate the LENGTH (number of bytes stored in the SAS datasets) with the WIDTH of the format used to DISPLAY the value as text.
Thank you all for such quick replies. It's my first time posting here, and I have already found the SAS Community so friendly and helpful.
I did leave out some important details:
By reading @FreelanceReinh's post, I realized that this could be a problem with rounding. I'm new to SAS and found it strange that SAS "does not" differentiate between int and float types and instead only has "numeric". Thanks to your post, I've learned that there are ways to debug SAS like in other languages.
SAS datasets have two data types. Fixed length character strings and floating point numbers.
The DATE formats will ignore fractions of a day.
822 data _null_; 823 now=today(); 824 do offset=0,1,-1,-0.5,+0.5 ; 825 new=now+offset; 826 put offset= new= new= date9.; 827 end; 828 run; offset=0 new=22749 new=14APR2022 offset=1 new=22750 new=15APR2022 offset=-1 new=22748 new=13APR2022 offset=-0.5 new=22748.5 new=13APR2022 offset=0.5 new=22749.5 new=14APR2022
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Ready to level-up your skills? Choose your own adventure.