LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 1999, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 18 Nov 1999 13:04:49 +0000
Reply-To:     roland.rashleigh-berry@virgin.net
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Roland <roland.rashleigh-berry@VIRGIN.NET>
Organization: N/A
Subject:      Re: Simple Date Problem
Content-Type: text/plain; charset=us-ascii

Minsup Song wrote: > > Dear > > 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; > Run; > > 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; > Run; > > 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)

Roland


Back to: Top of message | Previous page | Main SAS-L page