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.

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
  • 2 replies
  • 804 views
  • 0 likes
  • 3 in conversation