| Date: | Tue, 14 Oct 1997 10:44:04 +0200 |
| Reply-To: | Gerard.HANNEY@EUROSTAT.CEC.BE |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | Gerard Hanney <Gerard.HANNEY@EUROSTAT.CEC.BE> |
| Subject: | Character format to convert a 2 digit year to 4 digit year. |
| Content-Type: | text/plain; charset=us-ascii |
|---|
<WIN2607-971014084404-1F9A*/G=Gerard/S=HANNEY/O=EUROSTAT/PRMD=CEC/ADMD=RTT/C=BE
/@MHS>
X-LSVTag: MIME-Version: 1.0
X-LSVTag: Content-Type: text/plain; charset=us-ascii
To: $PEER$ <SAS-L@VTVM1.CC.VT.EDU>
I need to produce a character format to read in a 2 digit year and
convert it to a 4 digit year correctly, i.e. 85 -> 1985, 00 -> 2000.
I have a version of the format working for numeric variables. How can
I convert it to produce a character 4 digit year?
I am using SAS 6.12 under UNIX.
<---- Copy of my SAS session Log ------>
621 /* =========== */
623 /* yy2yyyy.sas */
625 /* =========== */
626 proc format;
627 picture yyyy
628 0-<80 = '99' (fill='0' prefix='20')
629 other = '99' (fill='0' prefix='19');
NOTE: Format YYYY has been output.
630
631 value $yy2yyyy
632 '00'-'99' = [yyyy4.]
633 other = '9999' ;
NOTE: Format $YY2YYYY has been output.
634 run;
635 data work.yearnum;
636 input mm $2. ;
637 put @1 mm $2. @10 mm $yy2yyyy.;
638 cards;
80 2000 <= Wrong result
99 2000 <= ditto
00 2000
01 2000 <= ditto
79 2000 <= ditto
NOTE: The data set WORK.YEARNUM has 5 observations and 1 variables.
644 ;
645 run;
647
648 data work.yearchar;
649 input mm 2. ;
650 put @1 mm z2. @10 mm yyyy4.;
651 cards;
80 1980
99 1999
00 2000
01 2001
79 2079
NOTE: The data set WORK.YEARCHAR has 5 observations and 1 variables.
657 ;
658 run;
< ==================================================================>
****************************************************************
Gerard Hanney
Eurostat, Luxembourg.
Email: gerard.hanney@eurostat.cec.be
****************************************************************
|