[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: removing space from $_DATE

From   "Nick Cox" <>
To   <>
Subject   RE: st: removing space from $_DATE
Date   Sun, 22 Jun 2008 18:52:48 +0100

I do not know why you seem to feel frustrated. I would not expect Stata
to hold the same information in a multitude of slightly different ways,
which strikes me as unnecessary, inefficient and poor style. But I can't
see that as limiting in any way. You can work on the macro and use or
display the information in any format you wish. 

For example, this program (a) displays the current date in one
particular format, 
(b) defines a global macro containing that string (c) optionally, will
take another format. 

Naturally, you can vary the default format, change the macro name,
change the program so that a local macro is used instead or as well, and
otherwise extend or simplify the program. 

program cdate
	version 8.2 
	args format 
	local cdate = date("$S_DATE", "dmy") 
	if "`format'" == "" local format %dd_M_CY 
	di `format' `cdate' 
	global cdate = trim(`"`: di `format' `cdate''"') 


-----Original Message-----
[] On Behalf Of Raphael
Sent: 22 June 2008 04:03
Subject: Re: st: removing space from $_DATE

I was really hoping there were different date format macros for the
"current date" that I did not know exist. But the suggestions provided
are helpful.


On Fri, Jun 20, 2008 at 12:07 PM, Nick Cox <> wrote:
> Some small confusion here. The global macro in question is called
> and thus is referenced by $S_DATE: in fact it is usually better quoted
> as "$S_DATE" . It is an old-style equivalent of c(current_date).
> The strict answer to Raphael's question is that you can re-define this
> macro to be  without spaces, but it is better to display a copy that
> does not contain the spaces.
> As Svend's suggestion implies, this can be done via
> subinstr("$S_DATE", " ", "", .)
> Nick
> Svend Juul
> Raphael wrote:
> The macro $_DATE displays current as 20 Jun 2008. I am looking for a
> simply way to remove the spaces.
> That is, 20Jun2008.
> =====================================================================
> I did not succeed with $_DATE, but with c(current_date) it is:
>    . local z = subinstr(c(current_date) , " " , "" , .)
>    . display "`z'"
>    20Jun2008

*   For searches and help try:

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