Dear Statalisters,
I have a question regarding the creation of a variable, tag1, which I have been updating manually and would now like to automate.
For example:
For id = 1 on the date 24-May-2021, there were 4 SPS, so I set tag1 = 4.
For id = 3 on 24-May-2021, there were 3 SPS, so I set tag1 = 3. On 25-May-2021, there were 4 SPS, so I set tag1 = 4, and on 26-May-2021, there were 5 SPS, so I set tag1 = 5.
For id = 4 on 21-June-2021, there was 1 SPS, so I set tag1 = 1. On 28-June-2021, there were 3 SPS, so I set tag1 = 3, and on 29-June-2021, there were 5 SPS, so I set tag1 = 5.
How can I automate the creation of the tag1 variable in Stata to reflect the number of SPS on specific dates for each id?
Thank you for your help.
Sugan
I have a question regarding the creation of a variable, tag1, which I have been updating manually and would now like to automate.
For example:
For id = 1 on the date 24-May-2021, there were 4 SPS, so I set tag1 = 4.
For id = 3 on 24-May-2021, there were 3 SPS, so I set tag1 = 3. On 25-May-2021, there were 4 SPS, so I set tag1 = 4, and on 26-May-2021, there were 5 SPS, so I set tag1 = 5.
For id = 4 on 21-June-2021, there was 1 SPS, so I set tag1 = 1. On 28-June-2021, there were 3 SPS, so I set tag1 = 3, and on 29-June-2021, there were 5 SPS, so I set tag1 = 5.
How can I automate the creation of the tag1 variable in Stata to reflect the number of SPS on specific dates for each id?
Thank you for your help.
Sugan
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int id str16 sps float(date_sps tag1) 1 "admission" 22417 0 1 "apnea" 22424 4 1 "cessation intake" 22424 4 1 "rales" 22424 4 1 "unresponsive" 22424 4 1 "Death" 22424 . 2 "admission" 22417 0 2 "cessation intake" 22423 1 2 "unresponsive" 22424 2 2 "Death" 22424 . 3 "admission" 22418 0 3 "apnea" 22424 3 3 "cessation intake" 22424 3 3 "mottled" 22424 3 3 "rales" 22425 4 3 "unresponsive" 22426 5 3 "Death" 22426 . 4 "admission" 22419 0 4 "mottled" 22452 1 4 "apnea" 22459 3 4 "cessation intake" 22459 3 4 "rales" 22460 5 4 "unresponsive" 22460 5 4 "Death" 22464 . 5 "admission" 22420 0 5 "apnea" 22420 2 5 "mottled" 22420 2 5 "cessation intake" 22421 4 5 "unresponsive" 22421 4 5 "Death" 22421 . 6 "admission" 22420 1 6 "mottled" 22420 1 6 "cessation intake" 22421 3 6 "unresponsive" 22421 3 6 "rales" 22422 4 6 "Death" 22422 . 7 "admission" 22420 0 7 "apnea" 22488 2 7 "cessation intake" 22488 2 7 "mottled" 22489 3 7 "rales" 22490 5 7 "unresponsive" 22490 5 7 "Death" 22490 . 8 "admission" 22426 0 8 "cessation intake" 22432 1 8 "mottled" 22433 4 8 "rales" 22433 4 8 "unresponsive" 22433 4 8 "Death" 22433 . 9 "admission" 22426 1 9 "unresponsive" 22426 1 9 "cessation intake" 22427 3 9 "rales" 22427 3 9 "Death" 22428 . 10 "admission" 22427 0 10 "mottled" 22440 1 10 "cessation intake" 22442 2 10 "unresponsive" 22443 3 10 "Death" 22445 . 11 "admission" 22431 0 11 "apnea" 22574 2 11 "cessation intake" 22574 2 11 "unresponsive" 22576 3 11 "Death" 22576 . end format %td date_sps
Comment