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

st: RE: Listing un-formatted dates

From   "Nick Cox" <>
To   <>
Subject   st: RE: Listing un-formatted dates
Date   Wed, 23 Feb 2005 12:50:49 -0000

Yes, it is awkward but if you do it 
on the fly within a program, it is 
relatively painless. 

This hack points in one possible direction: 

------------------------------ listndf.ado 
*! 1.0.0 NJC list with no date formatting 
* syntax is just "listndf [varlist] [if] [in] [ , list_options ]"
program listndf 
	version 8.2 
	syntax [varlist] [if] [in] [, SUBVARname * ] 

	marksample touse, novarlist
	qui count if `touse' 
	if r(N) == 0 error 2000 

	foreach v of local varlist { 
		local format : format `v' 
		if inlist(substr("`format'",2,1), "d", "t") { 
			tempvar V 
			clonevar `V' = `v' 
			format `V' %7.0g 
			char `V'[varname] `v' 
			local tolist "`tolist' `V'"
		else local tolist "`tolist' `v'" 
	list `tolist' if `touse', subvarname `options' 


Eric G. Wruck
> I have a date variable that is in Stata date -- i.e., the number of 
> elapsed days since January 1, 1960.  This variable is formatted as 
> %dm-Y.  Is there a way to list the elapsed date values after I've 
> formatted them (I was thinking along the lines of <list, nolabel> but 
> can't find such an animal)?  I know I could always format the 
> variable back, or generate a new variable, but this strikes me as 
> somewhat awkward.

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index