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: AW: vertical (within a column) calculations
From
"Mendoza Aldana, Dr Jorge Antonio (WPRO)" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: AW: vertical (within a column) calculations
Date
Tue, 10 Aug 2010 17:29:59 +0800
Dear Martin,
Excellent, my sincere thanks for your help.
Jorge
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Martin Weiss
Sent: 10 August 2010 15:18
To: [email protected]
Subject: st: AW: vertical (within a column) calculations
<>
There are multiple entries with "lab==1", complicating matters:
*************
clear*
inp PLACE:mylabel str15 DATE LAB, auto
A "04 Mar 10" .
A "16 Mar 10" 2
A "17 Mar 10" 1
A "19 Mar 10" 2
A "23 Mar 10" 2
A "29 Mar 10" 2
A "30 Mar 10" 2
A "30 Mar 10" 2
A "31 Mar 10" 1
A "31 Mar 10" 1
A "01 Apr 10" .
A "01 Apr 10" .
A "01 Apr 10" 2
A "02 Apr 10" 2
B "07 Jun 10" 1
C "25 Jun 10" 2
D "07 Feb 10" .
D "03 Mar 10" .
D "01 Apr 10" 1
D "03 Apr 10" 1
D "04 Apr 10" 1
D "04 Apr 10" 1
D "07 Apr 10" 1
E "24 Jun 10" 1
F "02 Apr 10" .
F "09 Apr 10" 2
F "10 Apr 10" .
F "27 Apr 10" 1
F "07 Apr 10" 2
F "22 Apr 10" .
F "26 Mar 10" .
end
compress
li, noobs sepby(PLACE)
gen newdate=date(DATE, "DM20Y")
form newdate %tdDD_Mon_YY
drop DATE
bys PLACE (LAB): gen diff=newdate-newdate[1]
li, noobs sepby(PLACE)
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Mendoza Aldana,
Dr Jorge Antonio (WPRO)
Gesendet: Dienstag, 10. August 2010 05:50
An: [email protected]
Betreff: st: vertical (within a column) calculations
Dear all,
using Stata 10.1
I have a dataset with place, date and a variable lab that can take values
from 1 to 4, and also missing values. I would like to generate a variable
containing, for each place, the difference between the date of a record with
lab==1 (my reference record within a place) and the date of the other
records (within the same place).
I will appreciate very much if you could indicate the function(s) for doing
this or the link dealing with.
Thank you very much in advance
Jorge
------ Data example -----------
PLACE DATE LAB
A 04 Mar 10 .
A 16 Mar 10 2
A 17 Mar 10 1
A 19 Mar 10 2
A 23 Mar 10 2
A 29 Mar 10 2
A 30 Mar 10 2
A 30 Mar 10 2
A 31 Mar 10 1
A 31 Mar 10 1
A 01 Apr 10 .
A 01 Apr 10 .
A 01 Apr 10 2
A 02 Apr 10 2
B 07 Jun 10 1
C 25 Jun 10 2
D 07 Feb 10 .
D 03 Mar 10 .
D 01 Apr 10 1
D 03 Apr 10 1
D 04 Apr 10 1
D 04 Apr 10 1
D 07 Apr 10 1
E 24 Jun 10 1
F 02 Apr 10 .
F 09 Apr 10 2
F 10 Apr 10 .
F 27 Apr 10 1
F 07 Apr 10 2
F 22 Apr 10 .
F 26 Mar 10 .
----------------------
====================================================
This message was scanned for viruses with Trend Micro ScanMail, GFI
MailSecurity and GFI MailEssentials by the World Health Organization
Regional Office for the Western Pacific. However, the recipient is advised
to scan this e-mail and any attached files for viruses.
Disclaimer:
This e-mail, together with any attachments, is intended for the named
recipients only and is confidential. It may also be privileged or otherwise
protected by law.
If you have received it in error, please notify the sender immediately by
reply e-mail and delete it and any attachments from your system. You may not
copy or disclose its contents to anyone.
*
* 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/
====================================================
This message was scanned for viruses with Trend Micro ScanMail, GFI MailSecurity and GFI MailEssentials by the World Health Organization Regional Office for the Western Pacific. However, the recipient is advised to scan this e-mail and any attached files for viruses.
Disclaimer:
This e-mail, together with any attachments, is intended for the named recipients only and is confidential. It may also be privileged or otherwise protected by law.
If you have received it in error, please notify the sender immediately by reply e-mail and delete it and any attachments from your system. You may not copy or disclose its contents to anyone.
*
* 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/