[EpiData-list] Question re defining a new variable in EpiData Analysis

epidata-list at lists.umanitoba.ca epidata-list at lists.umanitoba.ca
Thu May 31 13:55:08 CDT 2012


Dear Kerry:

If the variable names of the two dates are DATEBEGIN and DATEEND, then 
possible the simplest way to create an interval in days is a single line:

gen i interval=DATEEND-DATEBEGIN

Using your approach, it is two lines:

define interval ####
interval=DATEEND-DATEBEGIN

If you want the interval in years with decimal points:

gen f interval=(DATEEND-DATEBEGIN)/365.25

The "gen" command is powerful: Enter "gen" (without the quotation marks) 
into the command line and press F1 and the help file tells you all about it.

Regards,

Hans



On 31-May-12 04:00, epidata-list at lists.umanitoba.ca wrote:
> Hello,
>
> I am a relatively new EpiData user and am now using EpiData Analysis.
>
> In EpiData Analysis I would like to create a new variable which will be the number of days between two dates which I have collected in my EpiData dataset.  I have started with "define" and the name of the new variable and the new variable will be a numeric variable of length 4. i.e:
>
> define smeartoreg1 ####
>
> However, I am having difficulty with the code for defining the number of days between two existing dates and would appreciate some advice on this. I think I am making a simple mistake that can easily be fixed.
>
> Many thanks.
>
> Kind regards, Kerri  		 	   		

-- 
Hans L Rieder, MD, MPH
Jetzikofenstr 12
3038 Kirchlindach
   Switzerland

Tel: +41 31 829 4577
Mob: +41 79 321 9122
Web: http://www.tbrieder.org




More information about the EpiData-list mailing list