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

From |
Steven Samuels <sjhsamuels@earthlink.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: AW: st: AW: problem with the generate command |

Date |
Tue, 3 Mar 2009 11:35:29 -0500 |

--

replace healthinit="" if healthinit==".." destring healthinit, gen(h) -Steve On Mar 3, 2009, at 10:23 AM, Eva Poen wrote:

Isabelle, Martin and Steven already gave you hints on how to proceed from here. Just a few comments: Your replace healthinit="" if "healthinit"==.. is incorrect syntax. The double quotes should be around the .. and not around healthinit. Next you tried replace healthinit="" if healthinit==".." which is correct syntax. You said "it does not work". Please be more specific. Does Stata give an error message (which is unlikely)? Or does it say "(0 real changes made)" which means that the string ".." cannot be found in your variable. In this case I suspect there are either leading and/or trailing spaces around .., or some other weird characters that came about by copy and paste. One thing you could try is replace healthinit="" if strpos(healthinit,"..")>0 Martin's advice to use -tab- and -tab, nolabel- after -encode- was just meant to show you what -encode- actually does. These commands would not change your data, therefore no change of behaviour was expected. If you get nowhere with string functions and/or regular expressions, try and explore other routes to get your data into Stata, e.g. StatTransfer, where you can declare a variable to be numeric from the outset. Eva 2009/3/3 <Isabelle.Roux@ehess.fr>:Dear all, Thank you very much for this helpful advice. Stata refuses to replace .. by a blank. I type: ******* replace healthinit="" if "healthinit"==.. ****** I have:"nothing found where name expected".If I try:*replace healthinit="" if healthinit==".."*, it does notworkbetter. Is there a problem with my command? Then when I write: ** encode healthinit, gen(H) ta H ta H, nolabel generate health=1.06*H ** I have the same resultas for health<> After your -encode- command, type ************* ta H ta H, nolabel *************and note the difference. -destring- is your command of choice,and payattention to Eva`s remark for the missings. HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Isabelle.Roux@ehess.fr Gesendet: Dienstag, 3. März 2009 12:29 An: statalist@hsphsun2.harvard.edu Betreff: Re: st: AW: problem with the generate command Dear Martin,Thank you very much for all your help since the beginning I useStata.Here are my data (just the beginning!): country healthinit H health Afghanistan 13.00 13.00 23.32 Albania 116.00 116.00 16.96 Algeria 76.00 76.00 169.6 American Samoa .. .. 1.06 Andorra 1922.17 1922.17 54.06 Angola 24.00 24.00 72.08 Antigua and Barbuda 492.00 492.00 138.86 Argentina 283.00 283.00 89.04 Armenia 53.00 53.00 145.22 Aruba .. .. 1.06Healthinit is the health expenditure per capita in currentdollars. It isa string variable. It comes from the wdi database. As I want them in euros, and that the exchange rate is 1.06 (year is 2003), I wrote to stata: encode healthinit, gen(H) generate health=1.06*H H is a long variable. Danke schön für die Helfe! Isabelle* * 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/

* * 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/

**References**:**st: Count data and endogeneity***From:*Meherun Ahmed <mahmed@carleton.edu>

**st: problem with the generate command***From:*Isabelle.Roux@ehess.fr

**Re: st: AW: problem with the generate command***From:*Isabelle.Roux@ehess.fr

**Re: AW: st: AW: problem with the generate command***From:*Isabelle.Roux@ehess.fr

**Re: AW: st: AW: problem with the generate command***From:*Eva Poen <eva.poen@gmail.com>

- Prev by Date:
**Re: AW: AW: AW: st: AW: problem with the generate command** - Next by Date:
**AW: AW: AW: AW: st: AW: problem with the generate command** - Previous by thread:
**Re: AW: st: AW: problem with the generate command** - Next by thread:
**st: Time-varying coefficient in -stcox-** - Index(es):

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