Bookmark and Share

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: use loop to add plots to scatter plot


From   "Harris, Linda J" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: use loop to add plots to scatter plot
Date   Sat, 23 Mar 2013 17:11:36 +0000

I have macros with names `antigen01' to `antigen40'

I want to create a two way graph with the following:

1)   scatter plots with a variable # of these items (approx 5 and not in numeric order), each with a different marker
2)   linear fits for the same items, with lines in the same color as the markers
3)   a linear fit that is based on the aggregate selection of items following to a selection of these antigens (say approx 5):

If possible, I would like to use a loop with a foreach statement rather than having to modify the specific items and # of items each time i ran this.
I know that the last line is wrong - just have no idea how to accomplish this


This is my first posting - hope I've done it right!  I'm also new to Stata programming, so hope this isn't too trivial a question.

example  - say want `antigen01',  `antigen04'  `antigen05'

twoway  ///
(scatter yvar xvar if ANTIGEN==`antigen01', mcolor(red)) ///
(lfit yvar xvar if ANTIGEN==`antigen01', lcolor (red)) ///
(scatter yvar xvar if ANTIGEN==`antigen04', mcolor(green)) ///
(lfit yvar xvar if ANTIGEN==`antigen04'), lcolor(green) ///
(scatter yvar xvar if ANTIGEN==`antigen05', mcolor(blue)) ///
(lfit yvar xvar if ANTIGEN==`antigen05', lcolor(blue)) ///
(lift yvar xvar if ANTIGEN oneof [`antigen01' `antigen04'  `antigen5'], lcolor(black))

Thank you,
Linda
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index