Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: String problem.


From   austin nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: String problem.
Date   Wed, 7 Sep 2005 14:58:01 -0400

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, adiallo5@worldbank.org <adiallo5@worldbank.org> 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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index