Bookmark and Share

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


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

st: RE: How do I create a new observation that is the sum of two observations?


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: How do I create a new observation that is the sum of two observations?
Date   Sat, 1 May 2010 22:42:37 +0200

<>

You can create new vars with -egen,total()- though, and -drop- the old ones:

***********
clear*
//100 obs
set obs 100

//10 vars
foreach var of newlist var1-var10{
	gen `var'=rnormal()
}

//number for addition
gen number=sum(mod(_n,2)==1)

foreach var of varlist var*{
	bys number: egen new`var'=total(`var')
}

drop var*
keep if !mod(_n,2)


l in 1/10

***********


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Aiyar, Shekhar
Sent: Samstag, 1. Mai 2010 22:06
To: '[email protected]'
Subject: st: How do I create a new observation that is the sum of two
observations?

I have a dataset with about 200 observations (rows) and 1000 variables
(columns). I want to add two of those observations (rows) together to create
a new observation. As far as I can make out, gen and egen can only be used
to create new variables, not new observations. Any ideas? Thanks.

Shekhar


****************************************************************************
*******
This e-mail is intended for the addressee(s) named above and any other use
is prohibited. It may contain confidential information. If you  received
this e-mail in error please contact the sender by return e-mail.

The Bank of England does not accept legal responsibility for the contents of
this message if it has reached you via the Internet, as Internet
communications are not secure. Any opinions expressed are those of the 
author and are not necessarily endorsed by the Bank of England.

Recipients are advised to apply their own virus checks to this message .
****************************************************************************
******* 


_____________________________________________________________________
This e-mail has been scanned for known viruses by the Messagelabs SkyScan
Service.

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

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index