Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long id double(height weight) 14 60 150 14 60 . 22 . 180 22 48 180 7 67 211 7 55 211 218 50 306 218 50 306 100 71 175 100 65 175 100 81 190 end
Code:
id 14 22 7 218 100
Ideally the corrected set would look like this (can I create new variables in this way?) :
id | height | height1 | weight | weight1 | height2 | weight2 |
14 | 60 | 60 | 150 | . | . | . |
22 | . | 48 | 180 | 180 | . | . |
7 | 67 | 55 | 211 | 211 | . | . |
218 | 50 | 50 | 306 | 306 | . | . |
100 | 71 | 65 | 175 | 175 | 81 | 190 |
The only things I thought of are using the -collapse- command, or I saw a -collapseunique-
I also thought if I could convert from long to wide, but I would need a "j" variable which I do not have here...
Could I create another variable "count" and this counts upward by 1 for each new occurrence of a unique "id" value? That would give me a repeating variable to use, although some would have counts of 2 and some may have 3 or 4 depending on how many duplicates there are.
0 Response to Can I Collapse or Reshape to Wide?
Post a Comment