Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: test the format isdate


From   "rasool.bux" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: test the format isdate
Date   Tue, 17 Dec 2013 14:03:38 +0000

Dear Nick,

Thanks for reply, and I have used it as follows:
*****************
  qui ds, has(format %td*) // or qui findname, format(%td*)
  local test "`r(varlist)'"
  foreach v of varlist `test' {
        tostring `v', replace usedisplayformat force
  }
******************
May be there is another good way. I have checked -confirm- command also but (confirm date variable `v') is not working. I have seen that macro at this link: http://www.stata.com/statalist/archive/2008-04/msg00892.html.

Kindly let me know if there is any command like it for checking type & format of a variable i.e. -isnumber/ isdate/ isstring.

Thanks & best regards
Rasool Bux

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Monday, December 16, 2013 7:41 PM
To: [email protected]
Subject: Re: st: test the format isdate

way to think more generally, as dates are typically defined only by their display formats.

ds, has(format %d*)

or

ds, has(format %td*)

would be simple examples.

-findname- (SJ) is of the same flavour, but more versatile.

Note that -tostring- is a Stata command, not a Stata function.
-isnumeric- (origin not explained by you) is presumably a Stata command, not a Stata macro. Using terminology from outside Stata is likely to confuse or bemuse.

All that said, -tostring- won't usefully save numeric date variables as string dates, unless you specify a date format.
Nick
[email protected]


On 16 December 2013 14:06, rasool.bux <[email protected]> wrote:
> Dear Statalist,
>
> I want to test the format of a variable in a program for conversion to string in a loop using the tostring function. If the format of a variable is %td then I want to save it in a string variable by using the tostring function.
>
> I have searched web I found the macro -isnumeric- . But I want to test
> the format also i.e. -isdate-
>
> Kindly suggest me in this regard.
>
> Thanks
> Rasool Bux
>
> ________________________________
>
> This e-mail may contain information that is privileged or confidential. If you are not the intended recipient, please delete the e-mail and any attachments and notify us immediately.
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


________________________________

This e-mail may contain information that is privileged or confidential. If you are not the intended recipient, please delete the e-mail and any attachments and notify us immediately.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index