[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: AW: AW: st: AW: problem with the generate command |

Date |
Tue, 3 Mar 2009 11:10:19 -0500 |

--

The data were tab delimited with no quotes. Here is the revised version. ************************************************* type d01.txt insheet country healthinit health using d01.txt, tab gen h3= trim(regexr(healthinit,"\.\.",".")) destring h3, gen(h) ************************************************** Output ************************************************ . type d01.txt Afghanistan 13.00 23.32 American Samoa .. 1.06 Andorra 1922.17 54.06 . insheet country healthinit health using d01.txt, tab (3 vars, 3 obs) . gen h3= trim(regexr(healthinit,"\.\.",".")) . destring h3, gen(h) h3 has all characters numeric; h generated as double (1 missing value generated) . ************************************************** . On Mar 3, 2009, at 10:18 AM, Martin Weiss wrote:

<> Good call, but still gives me " h3 contains nonnumeric characters; no generate" for the -destring- line. Maybe Isabell`s data are not easily transferred between bodies of email messages and applications, so anydifference in success between us may be entirely due to differencesin theinitial dataset. As attachments are prohibited on the list, it ishard tosee how to overcome this problem... HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von StevenSamuelsGesendet: Dienstag, 3. März 2009 16:12 An: statalist@hsphsun2.harvard.edu Betreff: Re: AW: AW: st: AW: problem with the generate command How about: ************************************************* clear insheet country healthinit health using d01.txt, names tab des list gen h3= trim(regexr(healthinit,"\.\.",".")) destring h3, gen(h) sum h health ************************************************** -Steve On Mar 3, 2009, at 8:54 AM, Martin Weiss wrote:<> Isabell`s data are weird, though. I have tried several approaches to make the "healthinit" numeric, and have not managed in Stata. -trim()- should kill the blanks surrounding the numbers in "healthinit" (so that - destring- can work on these data) but does not. The only thing that got them to behavewell was to clean the data with a plug-in for a well-knownspreadsheetapplication. 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 14:21 An: statalist@hsphsun2.harvard.edu Betreff: Re: AW: st: AW: problem with the generate command 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 pay attention 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 use Stata. 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.06 Healthinit is the health expenditure per capita in current dollars. It is a 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<> A bug in -generate- would be weird indeed. Give an excerpt of your data, and show us exactly what you typed and what Stata made of it... 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 10:08 An: statalist@hsphsun2.harvard.edu Betreff: st: problem with the generate command Hello, I have a health expenditure variable in current dollars, called H. It is a numeric variable ("long"). I called it "H". I want to convert it in euros, e.g to multiply by 1,6 so I write in my do-file: "gen health=1.6*H" I am very surprised because the results are wrong. It is very strange. For instance: H=13.00 and Health=23.32 (first observation) or: H=116.00 and Health=16.96 (2d one) or: H=76.00 and Health=169.6 Thank you very much for help Best regards 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/* * 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/* * 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/* * 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/

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

**Follow-Ups**:**AW: AW: AW: AW: st: AW: problem with the generate command***From:*"Martin Weiss" <martin.weiss1@gmx.de>

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

**st: AW: Count data and endogeneity***From:*"Martin Weiss" <martin.weiss1@gmx.de>

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

**st: AW: problem with the generate command***From:*"Martin Weiss" <martin.weiss1@gmx.de>

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

**AW: st: AW: problem with the generate command***From:*"Martin Weiss" <martin.weiss1@gmx.de>

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

**AW: AW: st: AW: problem with the generate command***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: AW: AW: st: AW: problem with the generate command***From:*Steven Samuels <sjhsamuels@earthlink.net>

**AW: AW: AW: st: AW: problem with the generate command***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: AW: linepattern/msymbol in Kaplan-Meier graph?** - Next by Date:
**Re: AW: st: AW: problem with the generate command** - Previous by thread:
**AW: AW: AW: st: AW: problem with the generate command** - Next by thread:
**AW: AW: AW: AW: st: AW: problem with the generate command** - Index(es):

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