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

st: converting to string

From   "Ban,R (pgt)" <>
To   <>
Subject   st: converting to string
Date   Mon, 22 Sep 2003 17:05:52 +0100

Dear all,
First of all thanks to Nick for the help with reshape.
I'm having a bit of trouble with my reshape command because not all the variables that are to be put together are of the same type. Namely, say a1, a2, a3, which are to be reshaped into a, are not all string.
In my case there's a lot of these occurences. So I want to know if there's an easy way to make all the variables that I _know_ are supposed to be string, string.
I tried:
unab forcestring : *name
foreach i of local forcestring {
    gen str1 xx`i' = ""
    replace xx`i' = string(`i')
    drop `i'
    renpfix xx
this gives me an error, because i realize now that string(`i') works only if  `i' is numeric. Now a forceful method would be to do _cap replace_, but i was wondering if there's something more elegant. Thanks so much.
-radu ban


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