Hi
I am running the below merge statement for two files--which are attached. When I run the statement, the values for CourtJurisdiction from each file are missrepresented in the merged file for both. In the underlying files, the value for NYS is 40426 and the value for NYC is 23213. In the merged file, the NYS is 40424 and the value for NYC is 23212.
I cannot seem to figure out why this is happening. There are many other files in this merge statement, but I just enclosed two for this example. There are also several processes that run before this statement. If anyone has any ideas, please let me know.
Paul
data overviewCourtJur2;
length County $ 50 Year 3 Filing $ 30 FilingType $ 30 AgeRange $ 30 CourtJurisdiction 3;
merge
s0FirstNysAllAge2006
S0FIRSTNYCALLAGE2006;
by County Year Filing FilingType AgeRange;
run;
You cannot store values of the size you are showing in 3 byte floating point. In general it is never a good idea to use numeric variables less that the default length 8.
You cannot store values of the size you are showing in 3 byte floating point. In general it is never a good idea to use numeric variables less that the default length 8.
Hi Data_null
That is fine and thanks, but how would that change the values like it is doing above?
Paul
By throwing away the rest of the number. If you try to put 8 bytes of data into 3 bytes of storage something gets lost.
Try this little example using the value 40426. You can see that when the three byte value is read back in the '40'x in the 4th byte is now '00'x.
data x;
length len8 8 len3 3 ;
len8=40426;
len3=len8;
run;
data _null_;
set x;
put (len8 len8 len3 len3) ( = z5. +1 = hex16. /);
run;
len8=40426 len8=40E3BD4000000000
len3=40424 len3=40E3BD0000000000
What Tom said.
SAS even has a function so you check it in a data step.
OK, I got it. And thanks for examples. I just re-ran it using 8 bytes and it works fine. Thank you both.
Paul
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.