Date: Thu, 28 Feb 2002 17:08:26 -0500
Reply-To: "Braten, Michael (Exchange)" <mbraten@BEAR.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Braten, Michael (Exchange)" <mbraten@BEAR.COM>
Subject: Re: help for Substr
Content-Type: text/plain
try
data date;
input @01 DATE YYMMDD8. ;
MONOFDATE = MONTH(DATE) ;
DAYOFDATE = DAY(DATE) ;
YEAROFDATE = YEAR(DATE);
CARDS;
19470114
19590814
19421128
19451228
19431006
19401012
19351221
19421216
19400322
19411016
;
PROC PRINT;
FORMAT MONOFDATE DAYOFADTE Z2. YEAROFDATE 4. ;
> -----Original Message-----
> From: Elmaache, Hamani [SMTP:Hamani.Elmaache@CCRA-ADRC.GC.CA]
> Sent: Thursday, February 28, 2002 4:57 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: help for Substr
>
> Hi there.
> I wante some help.
> I have data:
>
> data date;
> input date;
> cards;
> 19470114
> 19590814
> 19421128
> 19451228
> 19431006
> 19401012
> 19351221
> 19421216
> 19400322
> 19411016
> ;
>
> /* I wante separate it like this :
> year month day
>
> 1947 01 14
> 1959 08 14
> 1942 11 28
> 1945 12 28
> 1943 10 06
> 1940 10 12
> 1935 12 21
> 1942 12 16
> 1940 03 22
> 1941 10 16
> */
>
> /* I wrote the following code
> ; but it doesn't work . Why ? */
>
>
> data year;
> set date;
> year=substr(date,4);
> month=substr(date,5,2);
> day=substr(date,7,2);
> *put @1 year @15 month @25 day;
> run;
>
> /* But juste I got this: */
> proc print;
> run;
> /* I wante separate it like this :
> year month day
>
> 1947 01 14
> 1959 08 14
> 1942 11 28
> 1945 12 28
> 1943 10 06
> 1940 10 12
> 1935 12 21
> 1942 12 16
> 1940 03 22
> 1941 10 16
> */
>
> /* I wrote the following code
> ; but it doesn't work . Why ? */
>
>
> data year;
> set date;
> year=substr(date,4);
> month=substr(date,5,2);
> day=substr(date,7,2);
> *put @1 year @15 month @25 day;
> run;
>
> /* I got this: */
>
> Obs date year month day
>
> 1 19470114 19470114 19 47
> 2 19590814 19590814 19 59
> 3 19421128 19421128 19 42
> 4 19451228 19451228 19 45
> 5 19431006 19431006 19 43
> 6 19401012 19401012 19 40
> 7 19351221 19351221 19 35
> 8 19421216 19421216 19 42
> 9 19400322 19400322 19 40
> 10 19411016 19411016 19 41
****************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************
|