Bookmark and Share

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: Efficient code to generate many date/time variables at once


From   Alison El Ayadi <[email protected]>
To   [email protected]
Subject   st: Efficient code to generate many date/time variables at once
Date   Tue, 25 Mar 2014 16:12:36 -0700

Dear Statalisters -

I have to create a number of date/time variables using a %td formatted
date and a string time, which I generally do using the following code,
for each of the different time points -

gen dt_tm_drape_str = string(dt_drape,"%td") + " " + tm_drape
gen double dt_tm_drape = clock(dt_tm_drape_str,"DMYhm")
format dt_tm_drape %tc

I'd like to make my code more efficient by having it run through all
of the variables that I have, which are paired as dt_X and tm_X.  Any
suggestions on how to put together a program to do this?

Thanks,
Alison
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index