BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All

I am trying to do a "lookup" if you like into one dataset and replace the matching values in another dataset. EG

Dataset A has the following values

0100 23001
0101 23002

And dataset B has the following values

0100
0101

What i want to do is look into dataset A and grab the corresponding values - so in this case I want to replace 0100 with 23001 in Dataset B and likewise, 0101 will be replaced to 23002 by looking into Dataset A for the value.

I am on version 9 and on the mainframe.

Any help will be greatly appreaciated.

Thanks!
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You have some options depending on preference mostly:

1) DATA step: MERGE on common-sorted files.
2) PROC SQL: JOIN to combine tables on comon variable list.
3) PROC FORMAT and DATA step using a PUT function to perform the look-up.

Recommend some DOC review on the above, and likely, check the SAS Support website at http://support.sas.com/ for SAS coding samples and examples in SAS SUGI/SGF technical conference papers.

Another option is a http://Google.com/ advanced such as:

+lookup +example site:sas.com


Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Hi

Thanks for replying

I resolved this issue by using firstly a join (PROC SQL) on the two datasets. I had to do this twice because I wanted to update two columns in the dataset to be updated. Then i did a MERGE on the two VIEWS I created (via proc sql) - the merge was on a key field (serial number).

Cheers
Shelton.
darrylovia
Quartz | Level 8
Using the update statement in the data step in another option. The update is great b/c it only replaces non-missing values.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 826 views
  • 0 likes
  • 3 in conversation