Statalist The Stata Listserver

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

st: Re: RE: Re: first program

From   "Christer Thrane" <>
To   <>
Subject   st: Re: RE: Re: first program
Date   Thu, 1 Jun 2006 20:13:11 +0200


Referring to the code you posted below:

Is it possible to twitch it somehow so that it, for each unique person as defined by the person id variable, keeps only the observation form the last panel. In other words, I want to create a cross-sectional dataset in which the observations (one per person) may stem from different panels.

Best regards,

Christer Thrane

The code:

program balance, sort
version 8.2
syntax [if] [in]
marksample touse
tempvar count
qui {
local ivar: char _dta[iis]
if "`ivar'" == "" {
di as err "no identifier set"
exit 498
bysort `touse' `ivar': gen long `count' = _N
sum `count' if `touse', meanonly
keep if `count' == r(max) & `touse'

* For searches and help try:

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