Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: quick question
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
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: [email protected]
[mailto:[email protected]] On Behalf Of Lachenbruch,
Peter
Sent: Mittwoch, 17. Februar 2010 18:05
To: '[email protected]'
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: [email protected]
[mailto:[email protected]] On Behalf Of Austin Nichols
Sent: Tuesday, February 16, 2010 3:04 PM
To: [email protected]
Subject: Re: st: quick question
Tony <[email protected]> :
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
<[email protected]> 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/