[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: RE: generating new vars from old by cutting off a portion off the old
Nevertheless, your description "about 8" is worrying.
In any observations that have some other number
of characters, this solution may be incorrect. Try
. assert length(oldvar) == 8
> That worked beautifully, thank you. Just saved me five hours
> of banging
> my head against the wall.
> > Try
> > gen str State = substr(oldvar,4,2)
> > This assumes that your original variable was string.
> > I have a variable that has about 8 characters per
> observation and I need
> > to take 2 characters (4th and 5th characters) and generate
> them as new
> > variables representing state codes. So for example, the
> variable has as
> > one of its value CITNA134. The characters I need to extract are NA,
> > which
> > will be recoded as State code. How would I go about doing this?
* For searches and help try: