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

st: RE: -forval- with -inequal7-

From   "Stephen P. Jenkins" <>
To   <>
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 <>
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

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

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

Professor Stephen P. Jenkins <>
Director, Institute for Social and Economic Research
University of Essex, Colchester CO4 3SQ, U.K.
Tel: +44 1206 873374.  Fax: +44 1206 873151.  
Survival Analysis using Stata: 
Downloadable papers and software:

Learn about the UK's new household panel survey, the United Kingdom
Household Longitudinal Study: 

*   For searches and help try:

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