Date: Fri, 23 May 2008 09:15:08 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: Changing Default DATETIMEnn print format
On Fri, 23 May 2008 06:02:27 -0400, Peter Crawford
<peter.crawford@BLUEYONDER.CO.UK> wrote:
>On Wed, 21 May 2008 23:10:28 -0400, Howard Schreier <hs AT dc-sug DOT
org> <schreier.
>junk.mail@GMAIL.COM> wrlote:
>
>>On Wed, 21 May 2008 10:12:30 -0500, data _null_, <datanull@GMAIL.COM>
wrote:
>>
>>>Would the IS8601DT format suite your needs. You can associate this
>>>format with all datetime variable in all data sets. Then it is the
>>>"default" when using proc print or any other proc.
>>>
>>>If this is not suitable you can create a PICTURE format that will
>>>display dates, times, and datetimes in almost any arrangement you can
>>>imagine.
>>>
>>>data dt;
>>> dt='21MAY2007:17:37:00'dt;
>>> format dt is8601dt.;
>>> run;
>>>proc print;
>>> run;
>>>
>>>2007-05-21T17:37:00
>>>
>>>
>>>On 5/21/08, Friar Broccoli <EliasRK@gmail.com> wrote:
>>>> When doing a PROC PRINT of data containing
>>>> a DATETIMEnn value the default output format looks
>>>> like:
>>>>
>>>> 21MAY2007:17:37:00
>>>>
>>>> which is a real pain because such text cannot be
>>>> sorted by tools outside of SAS.
>>>>
>>>> Is there some way of changing the *DEFAULT* behavior
>>>> so the result looks more like:
>>>>
>>>> 2007-05-21:17:37:00
>>>>
>>>> I'm not hopeful that this is possible, but if I don't ask ...
>>>>
>>
>>As far as I know there is no way to get what you want to happen by
default.
>>PROC PRINT will use a specified format (either from the data set's
header or
>>from the PROC PRINT code). In the absence of such a spec, it uses its own
>>rules, which are kind of complicated and don't actually use formats, at
>>least not in the way which other procs do. Since datetime variables are,
>>fundamentally, numeric variables, you get something akin to a BESTw
format.
>>
>>As a rule, you always need to declare formats for date, time, and
datetime
>>variables if you want user-friendly presentation.
>
>of course Howard is correct, but some automation can be achieved with a
little macro
>programming.
>The data= parameter carries enough info, but as I don't think the
provision of alternate
>datetime formats can be enforced without generating semicolons, I think
the solution for the
>problem here could treat the whole proc print statement as the parameter
to a macro
>(parmbuf macro option will help)
>.
>First, the proc print statement would be generated.
>Then the macro would identify the dataset to be read, and for each
variable with a datetime
>format, the macro would generate a better datetime format statement.
>
>Of course that idea is untested because I haven't managed to test SAS
programs on this
>mobile(cell)phone, yet ;-)
>
>PeterC
Hi Peter,
I think if your mobile phone runs Vista, there should be no more problems
with V9.2. Ok, maybe attaching a DVD drive? But there should be a
bluetooth solution soon for that.
No Vista on your mobile? Maybe with its next release...
by the way: now I slowly understand the initial problem! Not to generate a
format which is ok, but to assign it automaticly to a datetime-variable?
How is a datetime variable identified? I think the only way for that is to
assume that all that variables are formatted with DATETIMEnn. Otherwise it
is simply a numeric variable like many others...
I hope that I'm on the right way now.
Gerhard
|