BookmarkSubscribeRSS Feed
hwangnyc
Quartz | Level 8

Hi everyone,

 

My main dataset that contains a list of people and their home address. I have another data set that contains addresses that belong to a specific development. I'd like to create create a new variable in the main dataset that indiciates if the addresses belongs to a development. It could be a simple yes / no. Any direction would be greatly appreciated. Here is some sample data:

 

Main Dataset:

 

IDAddressDevelopment
1208 PALADINO AVENUE0
24021 Broad Street1
3121 111 Street1
4123 456 Street1
5161-141 River Road0

 

 

Development address list:

4021 Broad Street
121 111 Street
123 456 Street
200-141 River Road
500 PALADINO AVENUE

 

Thank you.

2 REPLIES 2
nehalsanghvi
Pyrite | Level 9

Try this:

data main;
infile datalines truncover;
input ID address $ 3-25;
datalines;
1 208 PALADINO AVENUE
2 4021 Broad Street
3 121 111 Street
4 123 456 Street
5 161-141 River Road
;
run;

data development;
set main(where=(id in (2,3,4)));
drop id;
run;

proc sort data=main;
by address;
run;

proc sort data=development;
by address;
run;

*if record is present in both datasets, set Development to 1; 
data mainout;
merge main(in=a) development(in=b);
by address;
Development=(a and b);
run;

ballardw
Super User

Depending on the quality of your data you may need to do some things to get good matches. For instance you may have data in either of the data sets that is inconsistent about abbreviations for common address terms: Street may appear as St or St. Capitalization is another issue. You show one address with ALL CAPITOL LETTERS but not the others. If one data set has "208 PALADINO AVENUE" and the other "208 Paladino Avenue" then they may not match.

You may also need to insure there is only one space between each item.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1217 views
  • 0 likes
  • 3 in conversation