From | "Wallace, John" <[email protected]> |
To | "'[email protected]'" <[email protected]> |
Subject | st: egen fill() for string variables? |
Date | Wed, 1 Sep 2004 08:50:37 -0700 |
I've found the fill() function for egen to be a very valuable tool, but I recently found it doesn't work for repeating patterns of string values. For example, if I wanted to generate a variable containing "cat, dog, rat, fish" for a set of 100 observations, I would first -expand- the observations to 400 by using
.expand 4
and then using my idealized egen situation I'd type
.egen str4 animal = fill(cat, dog, rat, fish, cat, dog, rat, fish) /*possibly with double quotes enclosing the strings - e.g. "fish" */
does such a command exist somewhere?
If not, would a workaround such as the following work? (I'm not at a Stata enabled machine this morning)
.expand 4 .egen animal = fill(1,2,3,4,1,2,3,4) .label define critter 1 "cat" 2 "dog" 3 "rat" 4 "fish" .label value animal critter .decode animal, gen(str_animal)
Thanks John Wallace | Research Associate | Test Method Development AFFYMETRIX, INC. | 3380 Central Expressway | Santa Clara, CA 95051 | Tel: 408-731-5574 | Fax: 408-481-0435
|
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |