Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65092

looping over dates with formating

$
0
0
I have a bunch of dates reflecting date of joining (DOJ). I want to do a bunch of calculations for each DOJ. Before getting into the calculations I want to display the date through which I am looping through.

qui: levelsof DOJ, local(levels)
foreach l of local levels{
di "`l'"
...
}

The code above works, but it displays dates as integers. Is there any way to convert that into intelligible dates. I tried

qui: levelsof DOE, local(levels)
foreach l of local levels{
format `l' %tdMonth dd, CCYY
di "`l'"
...
}

but i get errors (see below) and I am not sure how to work around this without generating a new variable converting it into a date and then dropping it before exiting the foreach loop - that sounds inefficient. Thank you for any advise. I feel like I am missing something obvious here.

. qui: levelsof DOJ, local(levels)

. foreach l of local levels{
2. format `l' %td
3. di "`l'"
4. }
8174 invalid name
r(198);

Viewing all articles
Browse latest Browse all 65092

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>