Hi,

I am working with a medicinal tests dataset. Three tests can be prescribed. The doctor can prescribe zero tests, 1 test and or more than 1 test. Since I am working with all date variables, I cannot understand how should I figure out how many tests a patient has taken. I have destringed the string variables and tried egen = group() but it did not work.

The second question which I have is that how can I create a dummy to know if the treatment started before the results from the tests came out?

I have attached a sample from the data using dataex.

* Example generated by -dataex-. To install: ssc install dataex
clear
input long(case_id provider_id) float(_registration_date _cxr_date _smear_date _gx_date) str10 treatment_start_date
11136171 1072979 20305 20515 20515 . "."
11146734 1183451 20536 . . . "23-03-2016"
11151419 1070704 20032 20230 20230 . "08-10-2014"
11151541 1202495 20436 20435 20435 . "."
11155990 1087319 20553 . . 20554 "."
11156228 1071231 20606 20606 20606 . "."
11165714 1202495 20463 20462 20462 . "."
11166171 1087902 20057 19993 19993 . "30-11-2014"
11168819 1183759 20496 20496 20496 . "."
11173139 1075913 20453 . . . "31-12-2015"
11174311 1075077 20280 20280 20280 . "04-08-2015"
11176187 1068033 20566 20566 20566 . "."
11183100 1082682 20615 20615 20615 . "."
11183461 1075682 20051 . . 20052 "."
11192715 1070957 20054 20041 20041 . "."
11194803 1070308 20234 . . . "."
11199393 1082682 20181 20173 20173 . "."
11199637 1071242 20080 . . . "."
11200066 1073957 20556 20556 20556 . "."
11201643 1081275 20506 20564 20564 . "22-02-2016"
11203730 1071242 20054 20055 20055 . "."
11204251 1207308 20462 . . 20461 "."
11206063 1083935 20514 . . . "01-03-2016"
11210075 1202495 20416 20413 20413 20420 "."
11210632 1082682 20595 . . . "."
11212369 1085286 20177 20177 20177 . "."
11215145 1070286 20037 20456 20456 . "."
11215520 1085286 20179 20406 20406 . "."
11217549 1074506 20483 20482 20482 . "."
11218454 1070770 20209 20209 20209 . "."
11218583 1172484 20358 . . . "27-09-2015"
11220798 1072077 20159 . . . "12-03-2015"
11225084 1079506 20255 20256 20256 20256 "."
11227008 1073462 20598 . . . "24-05-2016"
11227889 1183759 20247 20464 20464 . "."
11229839 1068033 20593 . . . "19-05-2016"
11232384 1172484 20292 . . . "23-07-2015"
11235743 1183451 20221 . . 20225 "."
11236468 1183451 20436 . . . "14-12-2015"
11237994 1084550 20057 . . . "30-11-2014"
11242132 1171682 20176 . . . "29-03-2015"
11244996 1083935 20279 . . 20221 "."
11246493 1073462 20629 . . . "24-06-2016"
11246671 1082682 20402 20402 20402 . "."
11247681 1069737 20061 20269 20269 . "01-11-2014"
11248178 1071715 20191 20192 20192 . "."
11250892 1069319 20514 . . . "01-03-2016"
11252091 1074275 20147 . . . "."
11257383 1078110 20617 . . . "."
11261644 1068033 20410 20410 20410 . "."
11263393 1069539 20056 . . 20222 "16-09-2014"
11264704 1072088 20489 . . . "05-02-2016"
11266417 1071231 20613 20613 20613 . "09-06-2016"
11268764 1202495 20400 . . . "."
11269617 1202495 20426 20422 20422 . "."
11275967 1183451 20571 . . . "29-04-2016"
11277059 1086517 20126 20126 20126 . "."
11280585 1082913 20254 . . . "."
11280989 1073451 20338 . . . "."
11282699 1071737 20489 20489 20489 . "."
11288180 1085286 20623 20624 20624 20630 "21-06-2016"
11289912 1087913 20616 20617 20617 . "."
11290659 1136517 20238 . . 20356 "."
11291201 1073462 20119 20384 20384 . "."
11295205 1069231 20305 20305 20305 . "03-09-2015"
11296946 1202495 20489 . . . "."
11297573 1073957 20554 20554 20554 . "."
11297939 1207297 20446 . . . "24-12-2015"
11297988 1074506 20474 20474 20474 . "."
11298351 1082682 20330 . . . "."
11304653 1071044 20192 . . . "14-04-2015"
11306450 1072077 20605 . . . "31-05-2016"
11306539 1086330 20156 20547 20547 . "."
11306552 1070308 20285 . . . "16-07-2015"
11312061 1083033 20180 20182 20182 . "02-04-2015"
11312994 1087902 20481 20483 20483 . "03-02-2016"
11314652 1085055 20059 . . . "."
11315696 1084264 20065 20065 20065 . "."
11316392 1072968 20261 20261 20261 . "."
11317834 1202495 20344 . . . "13-09-2015"
11319537 1070495 20194 20376 20376 . "."
11326464 1085286 20414 20415 20415 . "."
11326849 1137077 20490 20490 20490 . "22-02-2016"
11328211 1070770 20230 20230 20230 20233 "25-05-2015"
11330418 1136528 20139 20143 20143 . "."
11335779 1136902 20599 . . . "25-05-2016"
11336100 1072319 20467 . . . "14-01-2016"
11336713 1075330 20058 . . . "07-08-2014"
11339420 1207286 20106 . . 20103 "."
11339739 1207297 20426 . . 20428 "10-02-2016"
11342361 1071286 20342 . . . "."
11345548 1073451 20353 20355 20355 . "."
11347541 1086055 20329 20462 20462 . "."
11349863 1083253 20132 . . . "12-02-2015"
11349891 1072319 20445 20445 20445 . "."
11350802 1068033 19940 . . . "05-08-2014"
11351392 1073957 20525 20525 20525 . "."
11351871 1202297 20395 20394 20394 . "."
11353565 1202495 20591 . . . "17-05-2016"
11356455 1072748 20305 20361 20361 . "."
end
format %td _registration_date
format %td _cxr_date
format %td _smear_date
format %td _gx_date
[/CODE]