BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello All,

I am trying to count respondents of a survey.. However the count has to be by address. Is there any kind of code that I can write to count address... Since addresses are so messy and start with charcters I am so lost on how to do it.
Right now I have it sorted by surveycd and house number but I need to count the address.

example of the data

Variables
SurveyNumber
HouseNumber
Street Address
ZipCode


Survey Number HouseNumber Street Address ZipCode

1 227 sue lane 254664
1 221 marsh lane 255486
3 2222 people street 25564

The house number is sorted but I can't count because I don't know how to count the street name.
2 REPLIES 2
ArtC
Rhodochrosite | Level 12
You could use the CATX function to create a single address variable, which you could then count using FREQ or MEANS/SUMMARY.
[pre]
address=catx(' ',number,street,city,state,zip);
[/pre]
Doc_Duke
Rhodochrosite | Level 12
You can do it with SQL

SELECT count(*) FROM
(SELECT DISTINCT zipcode, StreetAddress, HouseNumber FROM mydata);

This assumes that the StreetAddress variable is typed and spelled consistently. "sue lane" and "sue ln" would be considered different streets by the SQL code. If your data are large, you may want to invest in a program to regularize the StreetAddress field (MelissaData.com has some). You could do some of that in the data step with the perl expressions, but it is messy to address all the possibilities. Just dropping the "lane" or "street" is not sufficient; in Durham, NC, we have "Chapel Hill Rd", "Chapel Hill St", and "Chapel Hill Blvd" within the same ZIP code.

Street names are unique within ZIP code, so you need that for the uniqueness.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 620 views
  • 0 likes
  • 3 in conversation