Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining tables with null variable 1

Status
Not open for further replies.

DonaZ

Technical User
Oct 10, 2007
41
US
I cannot join the two tables because of the following problem:

Table 1 Table 2
Code Code Description
AA AA Blue
002 002 Red
Do not care
BB BB Purple
048 048 White
678 678 Pink


I'm trying to join the two tables so I can get the descriptions from table 2. It does not work? What can I do if the code is null but I have a description? (see the third code from the top).
Is it possible to capture that information "do not care" by joining the two tables?

Thank you for your time.

 
Hi Donaz,
There shouldn't be a problem just doing a straight join from table2 onto table1 using either MERGE in a datastep or a Proc SQL join, a blank value will join to a blank value (in fact this sometimes causes problems in my work), so I don't know what the problem here is. In what way is this not working for you?
Another method of doing this is loading the descriptions into a format. A not so well known method of Proc Format allows you to read a dataset into a format. Let me know if you want help doing that.

One issue that might cause problems in joining your 2 files together is if the CODE variables are of different lengths in the 2 datasets and are padded with spaces after the values. They might LOOK the same but to the computer, seem different.
I hope that this helps.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
You're right Chris it works. I looked at my codes from Table2 again and found duplicates.

Thank you for your patience while I keep making these dumb mistakes.
 
Donaz - If I had no patience for "dumb mistakes" as you call them, I'd have lost my temper with myself a long time ago.
Even now I still do things like that. The only difference is that having done it a few hundred times, I can pick the problem alot quicker :)

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top