*
;
/*
Subject: Re: Date in DD-MMM-YYYY
   Date: Mon, 3 Feb 1997 16:20:00 MST
   From: "Brian O. Mullin" 
Newsgroups: comp.soft-sys.sas


on   Fri, 24 Jan 1997 11:20:02 EDT   Ian Whitlock
 writes:

>   Subject: Date in DD-MMM-YYYY
>   Summary: Make a format.
>   Respondent: Ian Whitlock 
>
>   Gregory T Weber  wants to display dates
>   with dashes as in
>
>   >   01-JAN-1997
>
>   I would make a format to cover the range of dates on interest.  Here is
>   the code for January 97.  Change the loop control values to a suitable
>   range.
>
>        data fmtdata ( drop = temp ) ;
>           length temp $ 9 ;
>           retain fmtname 'tempdate' ;
>           do start = "01jan97"d to "01feb97"d - 1 ;
>              temp = put ( start , date9. ) ;
>              label = substr(temp,1,2)||'-'||
>                      substr(temp,3,3)||'-'||
>                      substr(temp,6,4) ;
>              output ;
>           end ;
>        run ;
>
>        proc format cntlin = fmtdata ;
>           value dashdate
>              "01jan97"d - "31jan97"d = [tempdate11.]
>              other = [date9.]  ;
>        run ;
>
>        data _null_ ;
>           d = today() ;
>           put d= dashdate11. ;
>           d = '01jan2000'd ;
>           put d= dashdate11. ;
>        run ;

>   I had to use the double format specification to allow an "other" group
>   format as introduced in 6.07. because I don't know how to do it using
>   CNTLIN.  Can someone simplify the code to eliminate the need for
>   TEMPDATE.?
>
>   Ian Whitlock
>


Ian's desire to construct the format in one step is definitely worthwhile.
 Format dashdate is dependent upon tempdate, and deleting tempdate from the
library will destroy dashdate as well.  In addition, processing time can
 increase when a format is constructed utilizing a previously defined
format.  Tech Report P-222 states"  You should use user-defined formats at
no greater than one level of nested depth.  The SAS System will support up
to five levels of nested depth, but the overhead requirements increase
dramatically with each additional level."  My tests do not always bear this
out; however, it does occasionally happen.


The following macro constructs source code for value formats and informats.
 Within that realm I believe that it supports all possible options, except
not sorted.

I am not sure that the code has been simplified.  However, the format
dashdate is no longer dependent upon tempdate.

Brian

 -----
Brian O.  Mullin
Idaho Division of Health,
Center for Vital Statistics and Health Policy
mullinb{dhwtowers/towers2/mullinb}@dhw.state.id.us
------
Example section, see at bottom  */

/***************************************************************************
******
     *  FILE:                        makefmt.sas
     *  AUTHOR:                      BRIAN O. MULLIN
     *  CREATION DATE:               08-03-96
     *  Last moddified:              1-29-97
     *  Copyright 1997 by Brian O. Mullin
     *
     *
     *
     *  EXTERNAL FILES CREATED:            file you specify with a filname
     *                                       statement prior to invoking the
     *                                       macro.  the filename is then a
     *                                       parameter in the macro call
     *
     *  EXTERNAL FILES USED (NOT SPECIFIED AS INPUT PARAMETERS):  none
     *
     *  DATA SETS CREATED: _null_
     *
     *  DATA SET VARIABLES CREATED:  __start
     *                               __end
     *                               __label
     *                               __value
     *                               __valuex
     *                               __rangop
     *                               i
     *                               note:   none of these variables can be
present
     *                                       on the input dataset.
     *
     *  DATA SETS CLEANED UP?:    by default
     *
     *  LOCAL VARIABLES CREATED (OTHER THAN PARAMETERS): no
     *
     *  GLOBAL VARIABLES CREATED: no
     *
     *  OTHER MACRO VARIABLES CREATED: no
     *
     *  PURPOSE:   the macro writes a flat file containing
     *               the source code for a value format or informat it is
similar to
     *               creating a format with catlin, except that instead of
the
     *               format being added to a format library the source code
is
     *               written to a flat file.
     *
     *               It offers more flexibility than cntlin.  A format can
be
     *               generated dynamically which inaddition to containing
     *               specified labels can be built on other formats or
informats
     *               without creating an interm format.
     *
     *               The macro is designed to produce the source code of a
value
     *               format or informat using the output dataset produced by
     *               cntlout.
     *
     *
     *
     *  PURPOSE  OF PARAMETERS:
     *
     *               filename: The file that the source code is to be
written to.
     *                       This parameter is required.  It is the only
parameter
     *                       required.
     *
     *               start:  this is the start of the range.
     *
     *               end:    this is the end of the range.  If an end
variable
     *                       is not specified, end defaults to start.
     *
     *               label:  this the label on the right hand side of the
variable.
     *
     *               fmtname:the name of the format being created.  This
defaults
     *                       to the name of the variable specified in start.
     *
     *               data:   the input dataset.
     *
     *               cond:   a subsetting condition to be placed on the
input
     *                       dataset.
     *                       i.e.
     *                               where x = 1;
     *
     *               type:   the type of the format or informat to be
created.
     *                       This parameter cna be either a variable or a
constant
     *                       string.  If it is a constant string, it must be
     *                       enclosed in quotes.
     *
     *                       It can take on the following values:
     *                               N - numeric format
     *                               I - numeric informat
     *                               C - character format
     *                               J - character informat
     *
     *                       this variable is documented in the SAS
Procedures Guide
     *                       pg 301.
     *
     *
     *               hlo:    this variable indicates the properties of a
particular
     *                       range of a format, which is specified by a
record in
     *                       the input dataset.
     *
     *                       It can take on the following values:
     *                               H - ending range is high
     *                               L - ending range is low
     *                               O - range is other
     *                               F - format or informat used for
formatted value
     *                                   or informatted value
     *                               I - numeric informat range (informat
defined
     *                                   with unquoted numeric range)
     *
     *                       This variable is documented in Tech Report
P-222 Changes
     *                       and Enhancements to Base SAS Software version
6.07 pg 210.
     *
     *                       currently the macro does not support
     *                               S - notsorted
     *                               R - round option
     *                               N - no ranges
     *
     *               sexcl:  Y if start range value is excluded
     *
     *               eexcl:  Y if end range value is excluded
     *
     *               replace:This is a constant unquoted string.  If the
value of the
     *                       macro parameter is YES then the proc format
option,
     *                       NOREPLACE, is not written to the flatfile.
     *
     * SPECIFICATIONS:
     *   %MAKEFMT  (
     *                FILENAME= fileref-specifing-source-code-destination,
     *               
     *               
     *               
     *               
;