Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

Re: st: Identify and Replace Values

From   "Tobias Friedli" <>
Subject   Re: st: Identify and Replace Values
Date   Mon, 12 Jul 2010 20:35:10 +0200

Thank you very much, it seems to work like a charm. Only Problem is, that the some Model-names contain spaces and then Stata says "invalid name". I know there is a command to relpace all the spaces by an underscore, but i can't find it anymore. Anybody knows this command? Thanks

On Mon, 12 Jul 2010 13:52:46 -0400
 Jeph Herrin <> wrote:
how about

 levelsof traded_model, local(traded)
 levelsof new_model, local(new)
 local onlytraded : list traded - new
 local onlynew    : list new - traded
 local others     : list onlynew | onlytraded

 replace traded_model="others" if inlist(traded_model,"`others'")
 replace new_model   ="others" if inlist(new_model,"`others'")


On 7/12/2010 12:18 PM, Hobst wrote:

I have a huge dataset containing automotive brand-swiching data. I have a
variable called traded_model and another variable called new_model. in order to output a symmetric swiching matrix i need to identify all the expressions
that are eigther only in traded_brand or only in new_brand and replace the
expression with "others". For example a model called "318d" exists in
traded_model but not in new_model, so all the "318d" should be replaced by

Does anyone have an idea how i can programm that? I dont get it to work, and
doing it manually is close to impossible as there are more than 1000
different model names.

Any help is much appreciated, thank you.
*   For searches and help try:

*   For searches and help try:

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