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, **statalist.org** is already up and running.

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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: quick question |

Date |
Wed, 17 Feb 2010 18:57:19 +0100 |

<> " many solutions used the split command - it choked on the variable other_rash - apparently it didn't like the underscore. I renamed the variable otherrash and it sort of worked, but gave me some strings and some numeric. " I do not buy the story about the underscore. Either a variable name is legal (according to the conventions set out in [U], 11.3), then all Stata commands will accept it "no questions asked", or it is not, which would prompt Stata to reject it the moment you try to introduce it. Did you specify the -destring- option to -split-? If not, exclusively string variables should have come out on the other end... HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Lachenbruch, Peter Sent: Mittwoch, 17. Februar 2010 18:05 To: 'statalist@hsphsun2.harvard.edu' Subject: RE: st: quick question Thanks to Austin - the problem is solved. To answer a couple of questions in the responses: 1. my goal is simply to count the number of 'other_rashes' - the encoding was to plug in as many different rashes as possible into one string variable. I could have looked at each rash individually, but most appeared only a few times, and I decided the best approach was to give the number. 2. many solutions used the split command - it choked on the variable other_rash - apparently it didn't like the underscore. I renamed the variable otherrash and it sort of worked, but gave me some strings and some numeric. Austin's worked and basically agreed with my manual solution (and I detected some errors in my coding! - nothing like a dose of humility for a Wednesday morning) 3. I'm about to try Martin Weiss's solution - haven't yet 4. I wanted to count the "0" as 0 - no rashes. I'll check the split command with Eric's option. Thanks you all for your rapid response. My next headache is a bunch of responses that have some coding the investigators haven't told me about. I don't think there's much the Stata list can do to resolve that, unless there's a new expression of disgust rather than grrr! Tony Peter A. Lachenbruch Department of Public Health Oregon State University Corvallis, OR 97330 Phone: 541-737-3832 FAX: 541-737-4001 -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Austin Nichols Sent: Tuesday, February 16, 2010 3:04 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: quick question Tony <Peter.Lachenbruch@oregonstate.edu> : There are many ways to go, and the optimal choice no doubt depends on what you might want to do with the data later, but try e.g. clear input str15 other "55.1" "0" "54.3" "0" "0" "55.2" "0" "0" "17.3;49.3" end g o=other if other!="0" replace o=subinstr(o,";"," ",.) g n=wordcount(o) l, noo On Tue, Feb 16, 2010 at 4:38 PM, Lachenbruch, Peter <Peter.Lachenbruch@oregonstate.edu> wrote: > I have a list of multiple diagnoses (rashes) and the typical one is quite rare. I decided to simply count the number of such diagnoses. The data look like (in the first 50 observations) > > +--------------------+ > | other_rash | > |--------------------| > 10. | 55.1 | > 11. | 0 | > 12. | 54.3 | > 13. | 0 | > 14. | 0 | > |--------------------| > 15. | 55.2 | > 16. | 0 | > 17. | 0 | > 18. | 17.3;49.3 | > 19. | 55.2 | > |--------------------| > 20. | 11.3;18.3 | > 21. | 0 | > 22. | 0 | > 23. | 0 | > 24. | 9.2;11.3;17.3 | > I would like to be able to count the number of other_rashes - I tried to find a string function that would do this count, I was unsuccessful. Am I missing something? It's not crucial as I've already done this manually, but I have several other variables to handle. * * 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**:**RE: st: quick question***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: quick question***From:*"Lachenbruch, Peter" <Peter.Lachenbruch@oregonstate.edu>

**Re: st: quick question***From:*Austin Nichols <austinnichols@gmail.com>

**RE: st: quick question***From:*"Lachenbruch, Peter" <Peter.Lachenbruch@oregonstate.edu>

- Prev by Date:
**st: RE: RE: quick question** - Next by Date:
**RE: st: quick question** - Previous by thread:
**RE: st: quick question** - Next by thread:
**RE: st: quick question** - Index(es):