« SAS coding fun | Main | The 2008 Salary Calculator »

Match Merge using Proc SQL

Here is some code I ran across to do matching and merging using Proc SQL.  I think I snagged it from someone on the SAS Google Group.

data oldids;
  infile cards;
  input idfield2 matchfield;
cards;
1 100
2 200
;

data unmatched;
  infile cards;
  input idfield2 matchfield;
cards;
. 100
. 200
;

PROC SQL NOPRINT;
  UPDATE unmatched
  SET idfield2 = (SELECT idfield2
  FROM oldids
  WHERE unmatched.matchfield EQ oldids.matchfield);
QUIT; 

View this code on my code snippet repository. 

Posted on Tuesday, June 3, 2008 by Registered CommenterJared in | CommentsPost a Comment

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>