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: AW: lag


From   "Klaus Pforr" <kpforr@googlemail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: lag
Date   Thu, 31 May 2012 11:06:00 +0200

<>

Dear Fabian,

I think that are correctly expecting that "sale[_n-4]" is missing for the first for observations. The problem is, that "sale[_n-4]" is evaluated as "." for _n<=4, but the boolean expression "sale<=sale[_n-4]" is - at least not necessarily - evaluated as missing for these obs. As sale is probably less than the pseudo-infinitely large "." (See: help missing), you will have "sale_decrease5=1" for these observations.

To catch this problem, you can add the assertion "& sale[_n-4]!=." to you if-condition.

best 

Klaus

__________________________________

Klaus Pforr
GESIS -- Leibniz Institut für Sozialwissenschaft
B2,1
Postfach 122155
D - 68072 Mannheim
Tel: +49 621 1246 298
Fax: +49 621 1246 100 
E-Mail: klaus.pforr@gesis.org
__________________________________


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von "Fabian Schönenberger"
Gesendet: Donnerstag, 31. Mai 2012 10:52
An: statalist@hsphsun2.harvard.edu
Betreff: st: lag

Dear Statalist
With the following command I want to generate a dummy variable; 1 if current sales are lower than 4 years ago, 0 if sales are larger for each company:

by cusip: generate sale_decrease5=0 if sale>sale[_n-4] by cusip: replace sale_decrease5=1 if sale<=sale[_n-4]

I expected for each cusip 4 missings at the beginning, since there is no _n-4. However, the command gives 1 for each cusip in the first four years. 

How do I have to adapt the formula to get dummy variables after the first 4 years passed?

Many thanks in advance.

Fabian
-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                                  
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
*
*   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