I have a dataset that has two variables:
1) An identifier denoted here as MRN.
2) Test results
A single MRN can have multiple test results and these test results can be different.
I would like to create two new variables:
1) A count variable that would tell me number of tests done for each MRN.
2) A test result variable that would tell me whether test results are different for an MRN.
For example, for MRN 2414225, the value of first variable would be 2 and value of second variable would be 1.
Thanks
Anindit Chhibber
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long MRN byte Test_results 74153 . 74153 . 278770 . 278770 1 513168 . 513168 2 1094887 . 1094887 3 1094887 3 1221829 . 1221829 1 1221829 1 1248087 . 1248087 3 1248087 3 1303759 . 1303759 3 1303759 3 1328939 . 1328939 1 1866938 . 1866938 . 1915859 . 1915859 3 1967066 . 1967066 4 1978535 . 1978535 2 1978535 . 2162758 . 2162758 . 2167534 . 2167534 2 2316743 . 2316743 3 2414191 . 2414191 3 2414225 . 2414225 2 2414225 3 2547115 . 2547115 2 2821965 . 2821965 . 2821965 . 2857142 . 2857142 4 3023793 . 3023793 1 3190469 . 3190469 3 3285673 . 3285673 4 3689726 . 3689726 . 3756996 . 3756996 3 3756996 2 3774577 . 3774577 3 3872447 . 3872447 . 3877198 . 3877198 2 3936622 . 3936622 2 4089785 . 4089785 . 4126793 . 4126793 1 4160321 . 4160321 2 4160321 1 4177879 . 4177879 . 4231270 . 4231270 3 4231270 2 4240743 . 4240743 1 4265823 . 4265823 3 4272878 . 4272878 2 4299731 . 4299731 2 4299731 . 4299731 3 4467296 . 4467296 4 4473526 . 4473526 4 4572897 . 4572897 . 4572897 4 4664181 . 4664181 . 4733234 . 4733234 3 4933099 . end
0 Response to Different Numbers Across An Identifier
Post a Comment