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

Re: st: String problem.

From   austin nichols <>
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:

input hv001 hv002 hv003
1 1 2
1 121 3
1 10101 5
1 10101 105

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, <> 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:

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