Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

re:st: flagging significant values in a variable

From   Partho Sarkar <[email protected]>
To   [email protected]
Subject   re:st: flagging significant values in a variable
Date   Sat, 3 Mar 2012 19:40:21 +0530


I am afraid you haven't spelt it out very clearly! Based on one
possible interpretation, this would be one way to do it (shown only
for the LCI (renamed lci) variable):

---------------------------START CODE-------------------------------------------

egen natlci=total(lci*(region==99)) // generates a value for each
obs., equal to national value)
local tol .0001  // define tolerance for "significantly lower or higher"
gen byte tag= .
if lci-natlci>`tol' {
replace tag=1
else if lci-natlci< -`tol' {
replace tag= 2
else {
replace tag = 0

---------------------------END CODE-------------------------------------------

Hope this helps


			From	  Tim Evans <[email protected]>
			To	  "'[email protected]'" <[email protected]>
			Subject	  st: flagging significant values in a variable
			Date	  Fri, 2 Mar 2012 09:24:46 +0000


			I have a dataset that has variables of rates, LCI and UCI for a
number of regions in addition to a national average (rate, LCI, UCI)
so that it looks like this:

			rate		LCI		UCI		region
			0.9727	0.9583	0.9849	1
			0.9713	0.9523	0.9867	2
			0.9835	0.9667	0.9971	3
			0.9790	0.9741	0.9836	99

			What I would like to do is generate a flag beside each row that
will flag up entries where they are significantly higher (1) or lower
(2) or not significantly different (0) to region 99 - I'm unsure as to
the code here and would appreciate any advice. I'm using Stata 11.2.
*   For searches and help try:

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