Date: Thu, 18 Nov 1999 13:04:49 +0000
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Roland <roland.rashleigh-berry@VIRGIN.NET>
Subject: Re: Simple Date Problem
Content-Type: text/plain; charset=us-ascii
Minsup Song wrote:
> Hello. I have a simple(?) problem. In the data set, there are date (year)
> variable. For example,
> OBS Date
> 1 1970
> 2 1971
> 3 1973
> ... ...
> I would like to extract some observation by Date. For example, I would like
> to extract observation of which date is 1971. But unfortunately, when I
> enter the command as below,
> Data temp;
> Set Above;
> If Date=1970;
> Then, there is no observation. I find out why. The date is formatted by
> the date of 1960. 1.1. For example, when I give the range like below,
It depends how you have stored this date. A date contains a day and
month as well as a year. Internally it is the number of days since
01jan60. Or have you stored just the year as an integer? If you have
then "if date=1970" should work. But if you have stored it as a normal
SAS date then you must use the test "if year(date)=1970".
> Proc Print Data=Temp;
> Where 3000<=Date<=5000;
> I can see observations of which date is about 1970s. How can I treat this
> variable? Can I use the Date variable more easily?
This is because 1970 is 10-11 years after 01jan60 and so the day range
is 3650-4014 days since a SAS date is the number of days since 01jan60.
Use the test "if year(date)=1970" and it will work.
> Thank you.
You're very Wellcome. :o)