Hello,
I am trying to merge (1:1) two data sets by a common variable: a 10-digit UserID. Unfortunately, this variable has different Types and Formats in my datasets: it is Type = double and Format = %10.0g in the one and Type = str10 and Format = %10s in the other. All else equal I prefer converting the numeric version to the string rather than the other way around. So I tried
decode UserID, generate(UserID_str)
and received the following message:
UserID not labeled
r(182);
I am not a skilled Stata user, but judging from the error message I feel that 'decode' could be specifically suited for situations when one wants to create a new string variable based on the numeric values in the original. So not the solution I am looking for. Attempts to use 'recast str10 UserID' and 'g UserID_str = string(UserID, "%010.0f"' were equally underwhelming. Could someone please help me with this?
Many thanks in advance.
Sincerely,
Gayaneh
I am trying to merge (1:1) two data sets by a common variable: a 10-digit UserID. Unfortunately, this variable has different Types and Formats in my datasets: it is Type = double and Format = %10.0g in the one and Type = str10 and Format = %10s in the other. All else equal I prefer converting the numeric version to the string rather than the other way around. So I tried
decode UserID, generate(UserID_str)
and received the following message:
UserID not labeled
r(182);
I am not a skilled Stata user, but judging from the error message I feel that 'decode' could be specifically suited for situations when one wants to create a new string variable based on the numeric values in the original. So not the solution I am looking for. Attempts to use 'recast str10 UserID' and 'g UserID_str = string(UserID, "%010.0f"' were equally underwhelming. Could someone please help me with this?
Many thanks in advance.
Sincerely,
Gayaneh
Comment