Hi,
I want to merge 2 datasets based on two variables, namely CIK and Year. However, in one dataset the CIK codes has leading zeros while in the other dataset there are no leading zeros. For instance, 0000001750 and 1750, or 0012480089 and 12480089. I want to include leading zeros to the values that do not contain leading zeros. I assume this is the problem when I want to merge.
When I try this command:
I get the "Type mismatch" error
I also tried these codes:
I just don't get which command to use. I need to get 10-digit numbers, and my variable is a string. The screenshot shows how my data looks now.
Thanks in advance, if you need more information please let me know!
Josephine
I want to merge 2 datasets based on two variables, namely CIK and Year. However, in one dataset the CIK codes has leading zeros while in the other dataset there are no leading zeros. For instance, 0000001750 and 1750, or 0012480089 and 12480089. I want to include leading zeros to the values that do not contain leading zeros. I assume this is the problem when I want to merge.
When I try this command:
Code:
format CIK %010.0f
I also tried these codes:
Code:
gen str10 z = string(CIK, "%10.0f") gen str10 z = string(CIK, "%10.0g")
Thanks in advance, if you need more information please let me know!
Josephine
Comment