Statalist


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

st: Re: Loop programming


From   "Sherriff, Martyn" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: Re: Loop programming
Date   Thu, 7 May 2009 12:22:01 +0100

Sacrificial
Sacrificial

Sorry - forgot the truncated line problem

I have an analysis where I need to compare a set of repeat measurements to a known standard value and then visualise the data in a stripplot with the standard value as a reference line, and this is repeated over several different systems and each system has a different standard value. Eventually there will be in excess of 100 systems.

	I have used a simple forvalues loop for this, but my problem is how to get the standard values into the loop. My crude and inefficient solution is to add standard values to the dataset, calculate their mean value, and then use this as the reference.

set more off
forvalues i=1/7{
	di "`: label (sys) `i''"
	qui{
		su ts if sys==`i'
		local tsm=r(mean)
	}
	ttest m=`tsm' if sys==`i'
	stripplot m if sys==`i',over(bn) vert bar stack separate(set) title("`: label (sys) `i''") yline(`tsm')
	}
set more on

	Is there a straight forward method of getting these standard values into the loop? Eventually there will be in excess of 100 systems.

Many thanks,
Martyn


*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index