Question re defining a new variable in EpiData Analysis
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
On 2012-05-31 04:00, epidata-list@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.
The simple sollution is to make an expression where the two date variable are subtracted from eachother:
smeartoreg1 = datevarend - datevarstart
This will give you the number of days between two dates in the variables.
Here is a small example of how it works - paste this into the Editor of Analysis (F5) and run (F9) then you should see how the date differences are calculated:
---------------------------------------
close generate 20 gen d d1 = dmy(1,1,2000) + _n gen d d2 = dmy(1,2,2000) + (_n * 2) gen i daysdiff = d2 - d1 browse
----------------------------------------
Kind regards, Torsten Bonde Christiansen EpiData Association.
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@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
Dear List.
The following major "bugs" in the current public release version have been fixed:
1 "Out of Memory" bug present in EpiData Manager in combination with Windows Vista or Windows 7. 2 Misplacement of the "Question/Variable label" if one moved a field into a section
Before moving these for download in the public release section, users are encouraged to test these.
Please download from Http://www.epidata.dk/testing.php
Manager v.1.1.2 EntryClient v.1.1.1.1
In particular those of you who experienced the problems.
Meanwhile we are continuing development and before long more aspects will be available for testing as announced recently.
Kind regards, Torsten Bonde Christiansen Jens Lauritsen
EpiData Association.
participants (1)
-
epidata-list@lists.umanitoba.ca