Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: set the date


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: set the date
Date   Wed, 9 Apr 2008 21:42:05 +0100

The first lesson is to use the on-line help, but after -search- if you
don't know
what entries to look up. So 

. search double 

points to help on -data types-. 

gen var1n = date("15/" + var1, "DMY") 

var2 sounds as if it is already as you want it. It is already numeric. 

For subtraction, use -

e.g. gen var3 = var2 - var1n 

P.S. the spelling is "Stata"! 

Nick
n.j.cox@durham.ac.uk 

STATA Dndee

I am new to STATA
I have 2 variables and want to set them as date with
as in the following:

1-Var1- Storage type str8, display format 0.9s. It has
month and year only like: 06/2005 . I want to assign
the day for it then set the day at 15 of each month :
15/05/2005.

2- Var2- Storage type double, display format %td and
writen like 26Nov2005. I want this to set it as date
and actualy don't know what double means.

3- Then I have to change them to numeric (var1n,
var2n) and substracte them: var3=var2n-var1n.


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index