Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: AW: RE: AW: vertical (within a column) calculations


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: RE: AW: vertical (within a column) calculations
Date   Tue, 10 Aug 2010 12:03:02 +0200

<> 


I have recommended it a thousand times:
http://www.stata-journal.com/sjpdf.html?articlenum=pr0004

I think we should have a FRSJ (frequently recommended stata journal)
articles section somewhere..



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Mendoza Aldana,
Dr Jorge Antonio (WPRO)
Gesendet: Dienstag, 10. August 2010 11:30
An: statalist@hsphsun2.harvard.edu
Betreff: st: RE: AW: vertical (within a column) calculations 

Dear Martin,
Excellent, my sincere thanks for your help.
Jorge


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: 10 August 2010 15:18
To: statalist@hsphsun2.harvard.edu
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: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Mendoza Aldana,
Dr Jorge Antonio (WPRO)
Gesendet: Dienstag, 10. August 2010 05:50
An: statalist@hsphsun2.harvard.edu
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/


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