Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: RE: RE: How to generate preceding dates from a particular date


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: RE: RE: How to generate preceding dates from a particular date
Date   Wed, 14 Apr 2004 19:08:20 -0400

if you can get your starting date as a Stata date (perhaps input month day
and year as 3 arguments)  you can then generate the required formatted date
strings like this:

args m d y
local dateanchor=mdy(`m',`d',`y')
forval i=1(1)39 {
local thisweek: di %dNDy (`dateanchor'-7*`i')
insheet using Q:\DS5\BILL.WE`thisweek'.csv, comma clear
etc...

}

The key to this code is using Stata's date formatting and the -local : di-
construct.

Michael Blasnik
michael.blasnik@verizon.net

----- Original Message ----- 
From: "MITRA PINAKI (MAR1PXM)" <mar1pxm@ups.com>
To: <statalist@hsphsun2.harvard.edu>
Sent: Wednesday, April 14, 2004 6:52 PM
Subject: st: RE: RE: How to generate preceding dates from a particular date


> Nick,
>
> Actually, what I am looking for is how to identify all the past weekending
> data sets from a particular reference date.
>
> I have an ado file like the following:
>
> prog def rptflex
> version 7
> set more 1
> pause on
> qui{
>   args mmddyy
>   insheet using Q:\DS5\BILL.WE`mmddyy'.csv, comma clear
>   tempfile tmp; save `tmp', replace;
>   <snip>
> }
> If I type rptflex 041004, I use weekending 041004 data set and then would
> like to bring all the data sets for past 9 months, which are by weekending
> dates. My question is how to create a series of weekending dates (always
> Saturday) from the current date, in this case, it is 041004 (April 10,
> 2004). I would like to bring the preceding weekending data sets which are
> for weekending 040304 (BILL.WE040304) and then 032704 (BILL.WE032704) and
so
> on till end of 9 months and compare with the current data (merge and
> subsequently, append the changes).
>
> Hope this clarifies my question. Is something like this attainable in
STATA?
>
> Thank you for your kind help.
>
> Sincerely,
>
> Pinaki Mitra
>


*
*   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