Hello all,
I have a dataset in Stata with a list of patients and their coded outcomes, and a list in excel describing what each coded outcome corresponds to.
Example:
Stata Dataset:
Excel Spreadsheet:
Is there an "automated" way to generate a new variable in stata such as outcome_defined and have it "search" the Excel Spreadsheet (either as an excel file or in Stata) and match the coded outcome with the corresponding disease. Matching the codes in the outcome columns to the disease state in the adjacent column.
To get:
I'm sure there is a better way to explain this very easily, but hopefully this makes sense.
Thank you very much!
I have a dataset in Stata with a list of patients and their coded outcomes, and a list in excel describing what each coded outcome corresponds to.
Example:
Stata Dataset:
| ID | outcome | days_enoll | visit |
| 001 | X1 | 10 | 1 |
| 002 | X2 | 30 | 1 |
| 003 | X3 | 34 | 3 |
| 004 | X1 | 77 | 1 |
| 005 | X5 | 74 | 1 |
| 006 | X6 | 1 | 1 |
| 007 | X9 | 99 | 1 |
| Outcome Code | Corresponding Disease |
| X1 | Disease 1 |
| X2 | Disease 2 |
| X3 | Disease 3 |
| X4 | Disease 4 |
Is there an "automated" way to generate a new variable in stata such as outcome_defined and have it "search" the Excel Spreadsheet (either as an excel file or in Stata) and match the coded outcome with the corresponding disease. Matching the codes in the outcome columns to the disease state in the adjacent column.
To get:
| ID | outcome | outcome_defined | days_enoll | visit |
| 001 | X1 | Disease 1 | 10 | 1 |
| 002 | X2 | Disease 2 | 30 | 1 |
| 003 | X3 | Disease 3 | 34 | 3 |
| 004 | X1 | Disease 1 | 77 | 1 |
| 005 | X5 | Disease 5 | 74 | 1 |
| 006 | X6 | Disease 6 | 1 | 1 |
| 007 | X9 | Disease 9 | 99 | 1 |
Thank you very much!

Comment