DATA Step, Macro, Functions and more

product code mapping issue

Reply
Contributor
Posts: 35

product code mapping issue

Hi,

    I have two datasets dataset a and dataset b.

    ex:dataset a

    id        value

    123      xyz

     456     wxy

  112345   abc

dataset b

id     product

123   def

456   tss

789   klm

i want to map product for each id in dataset a from dataset b

final dataset should look like this:

id             value    product

123           xyz      def

456           wxy      tss

112345      abc

I'm using left outer join on id....but not getting desired results.

how can i do this.

Thanks,

rk.

Super User
Posts: 17,831

product code mapping issue

A standard left join should work.

ie

proc sql;

create table want as

select a.id, a.value, b.product

from tablea a

left join tableb b

on a.id=b.id;

quit;

You can (should) post your code if something like the above isn't working for you.

Contributor
Posts: 35

product code mapping issue

Yes,the same code i have if i test on large dataset it is not working.

getting more records than actual records.

Regards,

rk

Super User
Super User
Posts: 6,500

product code mapping issue

Your right hand dataset must have duplicate records for the id variables.  If they are exact duplicates then adding the DISTINCT keyword after the SELECT keyword will reduce the number of records.

Ask a Question
Discussion stats
  • 3 replies
  • 123 views
  • 0 likes
  • 3 in conversation