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]
st: RE: quick question
From
"Nick Cox" <[email protected]>
To
<[email protected]>
Subject
st: RE: quick question
Date
Wed, 17 Feb 2010 11:27:52 -0000
Standing on everyone else's shoulders, a one-line solution appears to be
gen hashrash = cond(other_rash == "0", 0,
wordcount(subinstr(other_rash,";"," ",.)))
Nick
[email protected]
Lachenbruch, Peter
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 |
|--------------------|
25. | 0 |
26. | 0 |
27. | 2.1 |
28. | 15.2;23.2 |
29. | 19.2;55.2 |
|--------------------|
30. | 0 |
31. | 11.2 |
32. | 0 |
33. | 0 |
34. | 0 |
|--------------------|
35. | 0 |
36. | 0 |
37. | 57.2 |
38. | 7.1;11.2;29.2;55.3 |
39. | 0 |
|--------------------|
40. | 2.2;5.3;39.3 |
41. | 18.2 |
42. | 11.3;24.3 |
43. | 5.2;55.2 |
44. | 9.3; 10; 57.2 |
|--------------------|
45. | 46.3 |
46. | 7.2;46.1;55.1;57.1 |
47. | 0 |
48. | 5.2;9.2;15.2 |
49. | 3.2;7.2;9.2 |
|--------------------|
50. | 0 |
+--------------------+
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/