| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: help with loops
Dear Stata users,
I have a data set that looks like below. I want to graph a series of plots
where i plot on the same scatter the score by on several available dates for
the same person id. I need individual graphs for each Id. But i dont have a
continous running ID as some IDs are exlcuded due to no entries.
For example i dont have entries for ID=6 here so i dont need any graph for
this.
How can i make the program only to plot where ID exists?
by current program looks like this
local i=1
while `i'<=20 {
twoway (scatter score date if id==`i' & class=="AA", legend(label(1 "AA")
label(2 "BB")) ytitle("id"`i')) (scatter score date if id==`i' &
class=="BB" )
graph save child_`i'.wmf
local i=`i' + 1
}
+-----------------------------------+
| id date score class |
|-----------------------------------|
1. | 1 28 May 04 146 AA |
2. | 1 28 May 04 120 AA |
3. | 1 11 Mar 04 92 AA |
4. | 1 11 Mar 04 175 BB |
5. | 1 11 Mar 04 149 AA |
|-----------------------------------|
6. | 1 28 May 04 123 AA |
7. | 2 09 Jan 04 163 BB |
8. | 2 25 May 04 126 AA |
9. | 3 05 Feb 04 166 BB |
10. | 3 10 Jun 04 155 AA |
|-----------------------------------|
11. | 3 05 Feb 04 206 BB |
12. | 4 04 Mar 04 123 AA |
13. | 5 03 Jun 04 136 AA |
14. | 5 03 Jun 04 146 AA |
15. | 5 09 Jun 04 146 AA |
|-----------------------------------|
16. | 5 09 Jun 04 123 AA |
17. | 5 03 Jun 04 185 BB |
18. | 5 04 Mar 04 110 AA |
19. | 5 08 Mar 04 120 AA |
20. | 7 04 Mar 04 120 AA |
|-----------------------------------|
21. | 8 02 Mar 04 194 BB |
22. | 11 29 Dec 03 139 AA |
23. | 11 08 Mar 04 139 AA |
24. | 11 08 Mar 04 149 AA |
25. | 12 27 Feb 04 160 BB |
|-----------------------------------|
26. | 12 05 Feb 04 158 AA |
27. | 12 04 Mar 04 92 AA |
28. | 12 27 Feb 04 149 AA |
29. | 12 05 Feb 04 194 BB |
30. | 13 04 Mar 04 166 BB |
|-----------------------------------|
31. | 13 04 Mar 04 123 AA |
32. | 15 04 Mar 04 146 AA |
33. | 15 28 May 04 149 AA |
34. | 16 25 May 04 136 AA |
35. | 16 31 May 04 158 AA |
|-----------------------------------|
36. | 17 10 Mar 04 175 BB |
37. | 17 10 Mar 04 146 AA |
38. | 19 10 Jun 04 191 BB |
Thank you all in advance
Robert
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/