Hi all,
I have a dataset like this (see below), and what I want is a wide form (see the second table).
First, I want to check for each ID, if the combination of "staff" is identical (example in Bold is not expected). Since I have approximately 200,000,000 observations (I may split the dataset into small pieces if breaking the limits of reshape), I can't check one by one which is very awkward. If so(hopefully), how can I get a result like the second table?
Also, I would like to add a column (the number of items) for each item in the wide form.
I have no idea how to check the combination of staff" and add the column. The reshape code I can think of is,
Thanks very much!
I have a dataset like this (see below), and what I want is a wide form (see the second table).
ID | staff1 | staff2 | staff3 | item |
4 | Julie | Brian | Ben | a |
4 | Julie | Brian | Ben | b |
6 | Ben | Molly | Drew | f |
6 | Ben | Molly | Drew | f |
6 | Ben | Molly | Drew | g |
9 | Julie | Ben | Brian | h |
9 | Julie | Ben | Brian | a |
9 | Molly | Julie | Brian | e |
11 | Tiger | Ben | Ben | j |
...... | ...... | ...... | ...... | ...... |
ID | staff1 | staff2 | staff3 | item1 | amount1 | item2 | amount2 | item3 | amount3 | ...... |
4 | J | B | B | a | 1 | b | 1 | . | . | ...... |
6 | B | M | D | f | 2 | g | 1 | . | . | ...... |
9 | J | B | B | h | 1 | a | 1 | e | 1 | ...... |
11 | T | B | B | j | 1 | . | . | . | . | ...... |
Also, I would like to add a column (the number of items) for each item in the wide form.
I have no idea how to check the combination of staff" and add the column. The reshape code I can think of is,
bys id: gen n_id=_n
reshape wide item, i(id) j( n_id)
reshape wide item, i(id) j( n_id)
Comment