BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Paul_NYS
Obsidian | Level 7

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;

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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.

View solution in original post

5 REPLIES 5
data_null__
Jade | Level 19

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.

Paul_NYS
Obsidian | Level 7

Hi Data_null

That is fine and thanks, but how would that change the values like it is doing above?

Paul

Tom
Super User Tom
Super User

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

data_null__
Jade | Level 19

What Tom said.

SAS even has a function so you check it in a data step.

20         data _null_;
21            len8=40426;
22            do l=8 to 3 by -1;
23               lenl = trunc(len8,l);
24               put l= (lenl lenl ) ( = z5. +1 = hex16. /);
25               end;
26            run;

l=
8 lenl=40426  lenl=40E3BD4000000000
l=
7 lenl=40426  lenl=40E3BD4000000000
l=
6 lenl=40426  lenl=40E3BD4000000000
l=
5 lenl=40426  lenl=40E3BD4000000000
l=
4 lenl=40426  lenl=40E3BD4000000000
l=
3 lenl=40424  lenl=40E3BD0000000000
Paul_NYS
Obsidian | Level 7

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1065 views
  • 4 likes
  • 3 in conversation