I would like to collapse variables by an ID. For numeric variables everything is working fine. For string variables I realized that there is no option to concatenate strings. So I am looking for some kind of work around (possibly including bysort and egen) before collapsing variables.
This is how my data looks like.
And I would like to have:
So that when collapsing by ID, I can simply use the first concat value.
Even better would be if repeating values in Text would not be added to Concat, so that for ID 1 Concat would be "AD AR BD KL" and not "AD AR BD KL AD".
How do I do this in Stata?
Many thanks,
Milan
This is how my data looks like.
ID | Text |
1 | AD AR |
1 | BD KL AD |
2 | AD SJ |
2 | FD WE RS |
And I would like to have:
ID | Text | Concat |
1 | AD AR | AD AR BD KL AD |
1 | BD KL AD | AD AR BD KL AD |
2 | AD SJ | AD SJ FD WE RS |
2 | FD WE RS | AD SJ FD WE RS |
So that when collapsing by ID, I can simply use the first concat value.
Even better would be if repeating values in Text would not be added to Concat, so that for ID 1 Concat would be "AD AR BD KL" and not "AD AR BD KL AD".
How do I do this in Stata?
Many thanks,
Milan
Comment