I can't seem to find a solution for my problem, which is expressed in the following MWE:
I have data on accounts, jobs per account, date, and a string variable. e.g.
I need to merge all jobs within a specific account, for which the time range is less than a week (for example), without losing the text column.
I also want information on how many rows were merged.
In my example, the first two rows should be merged and concatenated (since their dates are within a week), but the last two rows do not change.
The data needs to look like this after the loop:
I have data on accounts, jobs per account, date, and a string variable. e.g.
Code:
clear input account job date str20 text 100 200 22640 "string a" 100 201 22645 "string b" 100 202 22670 "string c" 100 203 22690 "string d" end
I also want information on how many rows were merged.
In my example, the first two rows should be merged and concatenated (since their dates are within a week), but the last two rows do not change.
The data needs to look like this after the loop:
Code:
clear input account job date str20 text rows_merged 100 200 22640 "string a, string b" 2 100 202 22670 "string c" 1 100 203 22690 "string d" 1 end
Comment