search across all the following databases:
Data and documentation
Common questions and answers.
Entire collection of data resources.
I am having trouble merging selected files in the Health and Retirement Study (HRS). Some of the IDs are string variables and some are numeric. I am using stata.
I can convert the string ID to numeric with the following command:
generate HHIDNO = real(HHID);
However, when I try to convert the numeric ID back to string, something is not working and thus I cannot merge with the main file where the ID is a string variable. Here is the command I used to convert the numeric ID back to a string ID:
generate HHID = " " + string(HHIDNO);
When you converted the string ID to a numeric ID you dropped the original string ID. Don’t do this. Keep both versions of the ID in your original file. For merging, use whichever ID the ‘other’ data has (numeric or string).