BookmarkSubscribeRSS Feed
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Using SAS 9.4 

 

proc sql;
create table work.HN_Sepsis_merge_121918 as
select a.*, b.sepsis_code
from working.sepsis_HN_12182018 as a
left join raw.sepsis_codes_112918 as b
on a.diag_cd=b.diag_cd;
quit;

 

I am merging on diagnosis code and for the majority it is not a problem (eg. a04.7), however for some codes (eg. S00.31Xa) they are not matching when the code is in both datasets. All of the codes that are not matching have the same combination of numbers and letters. I have tried 'compress' to see if that was the problem and that did not work. Both are character variables with the same length, format and informat. Any ideas would be great, Thanks! 

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Show us an example of ACTUAL data in both of your data sets (a screen capture of actual data in each data set ought to be fine) (via a PROC PRINT output of a few records pasted into the {i} box) that doesn't merge properly. 

--
Paige Miller
novinosrin
Tourmaline | Level 20

Sir , Come on don't say screen capture, I am lazy to type. I would rather prefer as plain text for copy/paste or if OP is comfortable giving us in the form of datastep, even better. 

PaigeMiller
Diamond | Level 26

The reason I want a screen capture here of the data set is that there may be blanks at the beginning of the value that will prevent merging, and this will not be obvious if someone types text to represent the values. But I see your point, a PROC PRINT of a few records would work if done properly and pasted into the {i} box.

--
Paige Miller
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Their are not blanks, I used the compress and strip functions first to see if that was the issue

PaigeMiller
Diamond | Level 26

We want you to show us examples that don't merge. There are other reasons than blanks why they will not merge.

--
Paige Miller
ballardw
Super User

@GS2 wrote:

Their are not blanks, I used the compress and strip functions first to see if that was the issue


Null characters, ASCII 255, would not necessarily be removed by Compress, depending on actual Call. Strip won't remove nulls either.

 

Capitalization? X vs x

 

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