I wanna thank you guys cause i've got so many informations here. Followings are briefs of my data sheet, stnd_y person_id recu_day date sick_sym 2002 100 20020929 02-09-29 A 2002 100 20020929 02-09-29 B 2002 100 20020929 02-09-29 D 2002 100 20020930 02-09-30 B 2002 100 20020930 02-09-30 E 2002 100 20021002 02-10-02 X 2002 100 20021002 02-10-02 W 2002 101 20020927 02-09-27 S 2002 101 20020927 02-09-27 O 2002 101 20020928 02-09-28 C 2002 102 20021001 02-10-01 F 2002 103 20021003 02-10-03 G 2002 104 20021108 02-11-08 H 2002 104 20021108 02-11-08 A 2002 104 20021112 02-11-12 B And, I want to make above things as followings, stnd_y person_id recu_day date sick_sym Admission 2002 100 20020929 02-09-29 A 1 2002 100 20020929 02-09-29 B 1 2002 100 20020929 02-09-29 D 1 2002 100 20020930 02-09-30 B 2 2002 100 20020930 02-09-30 E 2 2002 100 20021002 02-10-02 X 3 2002 100 20021002 02-10-02 W 3 2002 101 20020927 02-09-27 S 1 2002 101 20020927 02-09-27 O 1 2002 101 20020928 02-09-28 C 2 2002 102 20021001 02-10-01 F 1 2002 103 20021003 02-10-03 G 1 2002 104 20021108 02-11-08 H 1 2002 104 20021108 02-11-08 A 1 2002 104 20021112 02-11-12 B 2 I mean, i want to make a variable of admission frequency personally with recu_day and date(this variables mean the date of hospitalization, and each person has several symptoms on every day, so recu_day and date are repeated.) And then, I used followings with sas, proc sort data=old out=new; by person_id recu_day; data new1; set new; retain admission 0; by person_id recu_day; if recu_day^=lag(recu_day) and(or) person_id^=lag(person_id) then admission+1; run; And also, data new1; set new ; by person_id recu_day; retain adm 0; if first.person_id and(or) first.recu_day then admission=admission+1; run; But, those are not working. How can i solve this? Please let me know about this. Thank you in advance! Obiter dictum, proc sort data=a out=a1; by person_id recu_fr_dt; data a3; set a1 ; by person_id recu_fr_dt; if first.person_id then adm+1; run; According to above codes, the results is following, as i don't mean it. stnd_y person_id recu_day date sick_sym Admission 2002 100 20020929 02-09-29 A 1 2002 100 20020929 02-09-29 B 2 2002 100 20020929 02-09-29 D 3 2002 100 20020930 02-09-30 B 4 2002 100 20020930 02-09-30 E 5 2002 100 20021002 02-10-02 X 6 2002 100 20021002 02-10-02 W 7 2002 101 20020927 02-09-27 S 1 2002 101 20020927 02-09-27 O 2 2002 101 20020928 02-09-28 C 3 2002 102 20021001 02-10-01 F 1 2002 103 20021003 02-10-03 G 1 2002 104 20021108 02-11-08 H 1 2002 104 20021108 02-11-08 A 2 2002 104 20021112 02-11-12 B 3 How could i fix it? Thank you! 😄
... View more