Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: -forval- with -inequal7-


From   "Stephen P. Jenkins" <[email protected]>
To   <[email protected]>
Subject   st: RE: -forval- with -inequal7-
Date   Wed, 16 Jul 2008 09:31:19 +0100

------------------------------

Date: Tue, 15 Jul 2008 09:09:07 +0000 (GMT)
From: Lola Jackson <[email protected]>
Subject: st: RE: -forval- with -inequal7-

(I've been trying to send this message since yeterday but it's not
appearing on the statalist, hope it does now...)



Apologies for some typos in my previous query, I copied and pasted my
code into my message and then modified it for the various commands but
mixed them up in the email.. However, this is not the problem. An
error message arises whenever there is a 'missing' date, using
-inequal7-.

The codes I have tried are as follows:

using forval:

g gini=.
qui forval i = 19901/20071 {
inequal7 income [fw=wei] if date==`i', returns
replace gini=r(gini) if date==`i'
}

and using foreach:

g gini=.
qui foreach i of num 19901/20071 {
inequal7 income [fw=wei] if date==`i', returns
replace gini=r(gini) if date==`i'
}

But with both get the error message:
'0' invalid obs no
r(198);

These do work when limited to 'consecutive' dates (eg 19901/19904),
the problem arises when they span  'missing' dates as there is no
19905. The programme runs and calculates the gini for the dates up
until a 'missing' date and then stops with an error. This is not a
problem with other commands using the same dataset, but has arisen
with -inequal7-.

===================================

Try using -levelsof- to create the vector that you then step through
using -foreach-

There is a inequality index example, using -ineqdeco-, in earlier
Statalist posts (search the Statalist archive).  See also the
-ineqdeco- help file




Stephen
-------------------------------------------------------------
Professor Stephen P. Jenkins <[email protected]>
Director, Institute for Social and Economic Research
University of Essex, Colchester CO4 3SQ, U.K.
Tel: +44 1206 873374.  Fax: +44 1206 873151.
http://www.iser.essex.ac.uk  
Survival Analysis using Stata:
http://www.iser.essex.ac.uk/teaching/degree/stephenj/ec968/ 
Downloadable papers and software: http://ideas.repec.org/e/pje7.html

Learn about the UK's new household panel survey, the United Kingdom
Household Longitudinal Study: http://www.iser.essex.ac.uk/ukhls/ 


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