Is there a command that would generate a new variable for each value of another variable? I've looked through the egen command manual but I'm not finding what I need.
I've received a raw dataset that only has two variables, besides the identifier and date. One called "code" is the variable name, and one called "value" has the actual value for that variable.
Note that there are repeated observations for each identifier, so I need a command that allows me to create a "long" file for each id and date combination, and then I may convert to wide format as needed.
The structure currently looks something like this, with both string and numeric entries in values:
id code value
a var1 1
b var1 2
a var2 1
b var2 4
a var3 unknown
b var3 5
And I'm aiming for this:
id var1 var2 var3
a 1 1 unknown
b 2 4 5
I've received a raw dataset that only has two variables, besides the identifier and date. One called "code" is the variable name, and one called "value" has the actual value for that variable.
Note that there are repeated observations for each identifier, so I need a command that allows me to create a "long" file for each id and date combination, and then I may convert to wide format as needed.
The structure currently looks something like this, with both string and numeric entries in values:
id code value
a var1 1
b var1 2
a var2 1
b var2 4
a var3 unknown
b var3 5
And I'm aiming for this:
id var1 var2 var3
a 1 1 unknown
b 2 4 5
Comment