/**********************************************************************/


   /* Example 1 - Creating a SAS date from a month and year     */
 
data one;
   input id mon yr;
cards;
1 01 95
2 06 94
3 11 95
4 12 90
;

proc sort;
   by mon yr;
run;

________________________________________________________________________

OUTPUT

OBS    ID    MON    YR
 1      1      1    95
 2      2      6    94
 3      3     11    95
 4      4     12    90


/**********************************************************************/


data two;
   set one;
   newdt=mdy(mon,1,yr);
   format mmyys5.;
run;

proc sort;
   by newdt;
run;

________________________________________________________________________

OUTPUT

OBS    ID    MON    YR    NEWDT
 1      4     12    90    12/90
 2      2      6    94    06/94
 3      1      1    95    01/95
 4      3     11    95    11/95


/**********************************************************************/


data one;
   input id monyr $;
cards;
1 JAN95
2 JUN94
3 NOV95
4 DEC90
;

data two;
   set one;
   tempdt='01'||monyr;
   newdt=input(tempdt,date7.);
   format newdt monyy5.
run;

________________________________________________________________________

OUTPUT

OBS    ID    MONYR    TEMPDT     NEWDT
 1      1    JAN95    01JAN95    JAN95
 2      2    JUN94    01JUN94    JUN94
 3      3    NOV95    01NOV95    NOV95
 4      4    DEC90    01DEC90    DEC90


/**********************************************************************/


   /* Example 2 - Creating a SAS date based on another SAS date */

data one;
   x='10apr95'd;
   new1=intnx('month',x,3);
   new2=intnx('month',x,-1);
run;

proc print;
   format x new1-new2 date9.;
run;

________________________________________________________________________

OUTPUT

OBS            X         NEW1         NEW2
 1     10APR1995    01JUL1995    01MAR1995


/**********************************************************************/


   /*  Example 3 - Determining the number of intervals between  */
   /*              SAS dates                                    */

data one;
   start='01jan96'd;
   end='31mar96'd;
   wkvar1=intck('week',start,end);
   wkvar2=intck('week2',start,end);
   wkvar3=intck('week.2',start,end);i
   wkvar4=intck('week2.2',start,end);
run;

proc print;
   format start end mmddyy8.;
run;

________________________________________________________________________

OUTPUT

OBS       START         END    WKVAR1    WKVAR2    WKVAR3    WKVAR4
 1     01/01/96    03/31/96      13         7        12         6


/**********************************************************************/