| Date: | Mon, 8 Dec 2008 10:34:13 +0200 |
| Reply-To: | =?windows-1255?B?4uPpIOHvICDg4ek=?= <GADI_B@MALAM.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | =?windows-1255?B?4uPpIOHvICDg4ek=?= <GADI_B@MALAM.COM> |
| Subject: | Re: SAS Negative Date Values |
|
| In-Reply-To: | A<b73b1924-5e51-4be6-a42a-3711b7c6d241@a12g2000yqm.googlegroups.com> |
| Content-Type: | text/plain; charset="windows-1255" |
You should use the INTCK function to calculate the difference between to dates.
Gadi
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of pritesh
Sent: Saturday, December 06, 2008 5:01 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: SAS Negative Date Values
On Dec 5, 6:54 pm, Virtual SUG <sfbay0...@aol.com> wrote:
> On Dec 5, 6:10 pm, pritesh <priteshka...@gmail.com> wrote:
>
> > I have a slight problem. I am trying to create an age variable for my
> > dataset. The problem I am having is that some patients were born in
> > 1920s or 1930s and therefore when I create an age variable, it is
> > negative in some cases. Is there a way for me to convert these
> > negative values to positive values so that I don't have a negative age
> > value (when I divide by 365) for patients? Thanks :)
>
> I think there's a misunderstanding here about how SAS stores the
> values of date variables in your data sets.
>
> A SAS date variable is the number of days before or after Jan 1,
> 1960. If, in your case, the patient was born on 1/1/1960, then their
> SAS date value is zero (0). If they were born after 1/1/1960, their
> birthday is stored as a positive integer, and if they were born BEFORE
> 1/1/1960, then their date value is a negative integer.
>
> I am not sure why you want to divide a SAS date variable's value
> representing someone's birthday by any value, much less 365. What is
> it that you are trying to accomplish? If you want to determine
> someone's age, you also need a starting point for the calculation,
> such as today, or yesterday, or some other "reference point."
>
> Please reply back to the list and clarify what it is your are trying
> to do. Also, you may want to read the SAS Language Reference:
> Concepts manual's chapter on SAS date/time handling. You can also
> download a PDF, at no charge, or my presentation, "Working with SAS
> Date and Time Functions," from the "user group presentations" link athttp://www.sierrainformation.com
>
> Hope this helps.
>
> Andrew Karp
> Sierra Information Serviceswww.SierraInformation.com
Sorry for not being clear earlier. I am trying to find out the age of
study participants from the day they were interviewed. So I used the
following code:
data work.alldata5;
set work.alldata4;
dob1=input(dob,mmddyy6.);
intdate1=input(intdate,mmddyy6.);
age=(intdate1-dob1)/365.25;
ageround=FLOOR(age);
run;
So the problem is that when I try to get age values for those born
before 1960, they will show up as negative values. Is there any way I
can rectify this? Thanks
|