The path of least resistance is probably to create numeric variables
from the substrings of your 12-character id variable, dump the string
version, and merge on multiple numeric variables (the datasets will be
smaller too).
But if you have your heart set on the string hhid:
clear
input hv001 hv002 hv003
1 1 2
1 121 3
1 10101 5
1 10101 105
end
gen str1 hhid=""
forval i=1/3 {
qui su hv00`i'
local le=length("`=r(max)'")
replace hhid=hhid+reverse(substr(reverse(" "+string (hv00`i')),1,`le'))
}
li, noo
On 9/7/05, [email protected] <[email protected]> wrote:
> hhid does not exist in my problematic data set.
> I was just testing on another set to see whether
> I could create hhid2 similar to hhid, ie with
> blanks and of 12 characters long. If it worked,
> I could apply the same on the set where the
> variable does not exist.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/