Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: seperate text in a variable repeatedly across many variables


From   Nick cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: seperate text in a variable repeatedly across many variables
Date   Sat, 26 Feb 2011 20:57:28 +0000

Possibly add a -gen()- option specifying

left quote
v
right quote
underscore

as stub. (This device is punctuation-challenged.)

Nick



On 26 Feb 2011, at 20:10, "Ben Ammar" <[email protected]> wrote:

Hi Nick & everybody,

first of all thanks for your answer. I tried what you suggested. Unfortunately that didn't work as I always got back "invalid syntax". Now I know why: Ususally Stata would put a stub of 1, 2 etc. at the end of each newly created variable. But since I got 100 variables (household_history1 up to household_history100) that I want to be separated, Stata isn't very happy that there are more than 9 variables. A varlist for household_history10 - household_history100 can be splitted and is no problem. I also tried the "generate()" option but that didn't work either.
Any ideas about how to split all variables including the first 10?

Thanks everybody!
-------- Original-Nachricht --------
Datum: Fri, 25 Feb 2011 08:43:13 +0000
Von: Nick Cox <[email protected]>
An: [email protected]
Betreff: Re: st: seperate text in a variable repeatedly across many variables

The syntax of your -foreach- call is wrong. Look again at the help to
see the forms alllowed and try

foreach v of var household_history_* {
           split `v', p(";")
}

Nick

On Fri, Feb 25, 2011 at 8:36 AM, Ben Ammar <[email protected]> wrote:

I'm new to Stata so please excuse if this question isn't the greatest:

I want to seperate a text (string) across several variables. In each
variable (household_history_1 up to household_history_100) there's a
semicolon. So I thought of:

.foreach household_history_* {
.split household_history_*, p(";")
.}

unfortunately Stata says "too many variables specified". Maybe the
approach is entirely wrong. I'd be very thankful for any comments!
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index