*SOLVED* Must convert numeric to string
When using
where:
oldvar1==92009660
oldvar2==WICUSTRTHHN8
my resulting concatenation is:
newvar==9.20e+07WICUSTRTHHN8
oldvar1 is numeric
oldvar2 is string
newvar is string as you would expect which is alright.
The last four digits of oldvar1 are just as important as the first two digits in identifying the observation so I need them to be present. To be clear - when I select the cell in the data editor the value above is exactly what is shown both in the cell and in the edit field at the top of the editor - unlike the case where it is shortened in visual form but stored correctly -such that it looks like e+07 but when you click on it, it shows the full number.
egen double and egen long do not fix the issue. I've tried format options like
to force a sufficient number of characters but to no avail. Any help would be much appreciated.
*EDIT*
After reading NJC's reply here: http://www.stata.com/statalist/archi.../msg00526.html perhaps I need to convert my numeric var into string first...I'll try that and chime back in.
*EDIT2* The above link mentions converting numeric into string. This solved the issue of exponential formatting of my numeric/concatenated data
Code:
tostring oldvar, gen(newvariable)
When using
Code:
egen newvar = concat(oldvar1 oldvar2)
oldvar1==92009660
oldvar2==WICUSTRTHHN8
my resulting concatenation is:
newvar==9.20e+07WICUSTRTHHN8
oldvar1 is numeric
oldvar2 is string
newvar is string as you would expect which is alright.
The last four digits of oldvar1 are just as important as the first two digits in identifying the observation so I need them to be present. To be clear - when I select the cell in the data editor the value above is exactly what is shown both in the cell and in the edit field at the top of the editor - unlike the case where it is shortened in visual form but stored correctly -such that it looks like e+07 but when you click on it, it shows the full number.
egen double and egen long do not fix the issue. I've tried format options like
Code:
, f(%45s)
*EDIT*
After reading NJC's reply here: http://www.stata.com/statalist/archi.../msg00526.html perhaps I need to convert my numeric var into string first...I'll try that and chime back in.
*EDIT2* The above link mentions converting numeric into string. This solved the issue of exponential formatting of my numeric/concatenated data
Comment