c**********5 发帖数: 653 | 1 my data
people id visit date location
1 1/20/2011 2
1 1/20/2011 1
1 1/20/2011 1
1 1/20/2011 2
1 1/20/2011 3
1 1/20/2011 3
1 1/20/2011 1
2 1/22/2011 4
2 1/22/2011 2
2 1/22/2011 1
2 1/22/2011 1
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 6
etc
What I want IS
people id visit date location
1 1/20/2011 2
1 1/20/2011 1
1 1/20/2011 2
1 1/20/2011 3
1 1/20/2011 1
2 1/22/2011 4
2 1/22/2011 2
2 1/22/2011 1
2 1/22/2011 5
2 1/22/2011 6
oR
What I want IS
people id visit date location
1 1/20/2011 21(fROM LOCATION 2 TO 1)
1 1/20/2011 12
1 1/20/2011 23
1 1/20/2011 31
2 1/22/2011 42
2 1/22/2011 21
2 1/22/2011 15
2 1/22/2011 56
I have over 10 locations and I AM TRYING TO FIGURE OUT HOW MANY ROUNTS HAVE
BEEN TRAVEL IN ONE DAY PER PERSON. |
p*******r 发帖数: 1951 | 2 data yourdata;
input id date mmddyy10. location;
if id = lag(id) and location = lag(location)
then delete;
cards;
1 1/20/2011 2
1 1/20/2011 1
1 1/20/2011 1
1 1/20/2011 2
1 1/20/2011 3
1 1/20/2011 3
1 1/20/2011 1
2 1/22/2011 4
2 1/22/2011 2
2 1/22/2011 1
2 1/22/2011 1
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 6
;
run;
【在 c**********5 的大作中提到】![](/moin_static193/solenoid/img/up.png) : my data : people id visit date location : 1 1/20/2011 2 : 1 1/20/2011 1 : 1 1/20/2011 1 : 1 1/20/2011 2 : 1 1/20/2011 3 : 1 1/20/2011 3 : 1 1/20/2011 1 : 2 1/22/2011 4
|
c**********5 发帖数: 653 | 3 Thanks,
Sorry ,Question is not finished yet |
c*********r 发帖数: 397 | 4 data b;
set a;
by p_id visit_date;
retain new_location;
if first.visitdate then new_location=location;
else do;
if new_location=location then delete;
else if new_location^=location then new_location=location;
end;
run;
if work out, please send me a baozi. hehe
I tried, it works.
【在 c**********5 的大作中提到】![](/moin_static193/solenoid/img/up.png) : my data : people id visit date location : 1 1/20/2011 2 : 1 1/20/2011 1 : 1 1/20/2011 1 : 1 1/20/2011 2 : 1 1/20/2011 3 : 1 1/20/2011 3 : 1 1/20/2011 1 : 2 1/22/2011 4
|
p*******r 发帖数: 1951 | 5 你要数多少travel就是 number of observation per ID per day - 1。这个应该自己会做吧?
【在 c**********5 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Thanks, : Sorry ,Question is not finished yet
|
y****n 发帖数: 46 | 6 data have;
length visit_date $10;
input people_id visit_date location;
cards;
1 1/20/2011 2
1 1/20/2011 1
1 1/20/2011 1
1 1/20/2011 2
1 1/20/2011 3
1 1/20/2011 3
1 1/20/2011 1
2 1/22/2011 4
2 1/22/2011 2
2 1/22/2011 1
2 1/22/2011 1
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 5
2 1/22/2011 6
;
run;
proc sort nodup data=have out=wants;
by people_id;
run;
proc print data=wants;
var people_id visit_date location;
run; |