Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How many records for the same persion in a given time period?

Status
Not open for further replies.

MScEpi

Technical User
May 22, 2011
1
CA
Hi,

I have a SAS data set with some 2 million records.

The records span a period of 5 years.

Many records are representative of the same person.

Each record has a variable for a service date.

I need to find out how many people have records with more than one service date in a seven day period, as well as how many people have multiple records in a one year period.

How can I do this? Would I use a Do loop command?

thanks!
 
There are different ways to do it - but I'd say NO to the do loop. I'd create new variables (based on your date field) for yr and wk (and possibly a combo yr-wk depending on if you need it). Then Proc Summary.
 
Simple Data Step can also do
1. Take original dataset worted with PersonID, Service date
2. Take 3 new variables last_serv_dt, wk_tot and yr_tot and reatin those variables
3. Use First. and last. on person ID
4. if service_date - last_serv_dt <7 then wk_tot+1
5. if year(last_serv_dt) eq year(service_date) then yr_tot +1

After this you can get the totals of week and year
that is wk_tot and yr_tot



sasbuddy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top