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

st: RE: displaying summary statistics of date variables


From   "Nick Winter" <nwinter@policystudies.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: displaying summary statistics of date variables
Date   Wed, 5 Feb 2003 16:21:15 -0500

Nick Cox has probably already written something for this (-:

However, the following is a quick and dirty program that'll do it.  It
could be made into a more general wrapper that detects the display
format of the variable, and only displays as dates the stats for
date-formatted variables, etc etc.

program define sumdate
	version 8
	syntax varlist , [ Format(string) ]

	if `"`format'"'=="" {
		local format %d
	}

	di
	di "{txt}    Variable {c |}       Obs        Mean    " ///
		"Std. Dev.        Min         Max"
	di "{hline 13}{c +}{hline 58}
	foreach v of local varlist {
		qui sum `v'
		local mean : di `format' r(mean)
		local sd   : di %9.0g r(sd)
		local min  : di `format' r(min)
		local max  : di `format' r(max)
		di "{txt}{ralign 12:`v'} " ///
			"{c |}{res}{ralign 10:`r(N)'}" ///
			"{ralign 12:`mean'}"		///
			"{ralign 12:`sd'}"			///
			"{ralign 12:`min'}{ralign 12:`max'}"
	}
end




-----------------------------------------------------------
 Nicholas Winter, Ph.D.                     P 202.939.5343
 Policy Studies Associates                  F 202.939.5732
 1718 Connecticut Avenue, NW     nwinter@policystudies.com
 Washington, DC 20009-1148           www.policystudies.com
----------------------------------------------------------- 

> -----Original Message-----
> From: Devra Golbe [mailto:Devra.Golbe@hunter.cuny.edu] 
> Sent: Wednesday, February 05, 2003 4:07 PM
> To: statalist@hsphsun2.harvard.edu
> Cc: Devra Golbe
> Subject: st: displaying summary statistics of date variables
> 
> 
> Is there a way to display summary statistics of (elapsed) 
> date variables 
> in  date format? For example, summary  of the following date variable 
> produces output which is difficult to interpret:  What, for 
> example, is the 
> latest  date in variable "date"?  15337 is difficult to interpret.
> 
>   I have checked the manuals, the web site, and the list 
> archives to no avail.
> 
> Thanks,
> Devra
> 
>   summ date
> 
>      Variable |     Obs        Mean   Std. Dev.       Min        Max
> -------------+-----------------------------------------------------
>          date |  317462    12376.24   1809.816       9000      15337
> 
> 
> 
> _____________________________________________
> Devra L. Golbe , Professor
> Department of Economics
> Hunter College
> 695 Park Ave., NY, NY 10021
> voice: 212-772-5408
> fax:    212-772-5398
> e-fax: 208-361-5964
> 
> *
> *   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/
> 
*
*   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