Date: Fri, 23 Mar 2012 09:25:16 -0700
Reply-To: Irin later <irinfigvam@yahoo.com>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Irin later <irinfigvam@YAHOO.COM>
Subject: Re: Strange problem with dates !
In-Reply-To: <CAM+YpE9jObDRRr9EgL1iYFQoMsJoYWRSk8w8SYmBCaiOvsGodQ@mail.gmail.com>
Content-Type: text/plain; charset=iso-8859-1
Thank you Joe. Yes, last statement is fixed already after Yevgeniy post.
I am still strugging with calciulation in SELECT statement , however.
I wonder if PROC SQL allow group of the same Parenthesis like I used in SELECT statement?
(a2.ServiceDateFrom-(a1.AdmitDate + a1.LOSp) ) as TimeFrame
From: Joe Matise <snoopy369@GMAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Sent: Friday, March 23, 2012 12:07 PM
Subject: Re: Strange problem with dates !
proc sql;
select * from sashelp.class
where
age = 15 or age = 13 and sex='M';
quit;
Your two ORs should be in a ( ) group together, otherwise the AND is only
applied to the second OR group - this is like + and *.
6+5*3
is 6+15=21 not 11*3=33.
-Joe
On Fri, Mar 23, 2012 at 10:57 AM, Irin later <irinfigvam@yahoo.com> wrote:
> Joe,
>
> LOSp is days . I multiply by 86400 but it did not resolve the problem.
>
> Besides how it explained the fact that the very last statement had no
> effect ...since datatype are identical?
>
> a2.ServiceDateFrom >= a1.AdmitDate
>
> *From:* Joe Matise <snoopy369@gmail.com>
> *To:* Irin later <irinfigvam@yahoo.com>
> *Cc:* SAS-L@listserv.uga.edu
> *Sent:* Friday, March 23, 2012 11:51 AM
> *Subject:* Re: Strange problem with dates !
>
> You need to be specific with what didn't work and how :) What is LOSp?
> It's just shown as number. Is it days, or seconds based? If it's Days
> based then you need to deal with the fact that your Admit Date and Service
> Date From are DATETIME (seconds, not days). You'd need either to convert
> LOSp to DATETIME, or multiply it by 86400 (# of seconds in a day), if it is
> indeed # of days.
>
> -Joe
>
> On Fri, Mar 23, 2012 at 10:44 AM, Irin later <irinfigvam@yahoo.com> wrote:
>
> Actually I used the following logic:
>
> Proc SQL;
> Create table Win14Time as
> select distinct
> a1.MemberPid
> ,a1.HospDischDate
> ,a2.claimid as OfficeClaimid
> ,a2.ServiceDateFrom as OfficeVisitDate
> ,a1.AdmitDate as AdmitHospt
> ,a1.LOSp
> ,a1.isPCP
> ,a1.PrimaryDiagnosisCode as HosptPrimDiag
> ,a2.PrimaryDiagnosisCode as OfficeVisitPrimDiag
> ,a1.EventID
> ,(a2.ServiceDateFrom-(a1.AdmitDate + a1.LOSp)) as TimeFrame
> FROM HospDischNoDup a1
> INNER JOIN HosptAC_VisitNodup a2 on a1.memberPid=a2.memberPid
> where
> (year(datepart(a2.ServiceDateFrom))=2010 and
> month(datepart(a2.ServiceDateFrom))in (7,8,9,10,11,12))
> or
> (year(datepart(a2.ServiceDateFrom))=2011 and
> month(datepart(a2.ServiceDateFrom))in (1,2,3,4,5,6))
> and a2.ServiceDateFrom >= a1.AdmitDate;
> quit;
>
> However , generated TimeFrame filed (number of day ) looks incorrect.
>
> Besides, the very last statement "a2.ServiceDateFrom >= a1.AdmitDate"
> does not work at all, does not restrict anything!!!!!
>
> this is my Proc Contents . Perheps, I need to convert dates first? How can
> I resolve it:
>
> # Variable Type Len
> Format Informat Label
> 6 AdmitHospt Num 8 DATETIME
> 22.3 DATETIME22.3 AdmitDate
> 11 EventId Char 50
> $50. $50. EventId
> 3 HospDischDate Num 8
> 9 HosptPrimDiag Char 8
> $8. $8. PrimaryDiagnosisCode
> 8 IsPCP Char
> 1 $1. $1. IsPCP
> 7 LOSp Num 8
> 11. 11. LOSp
> 1 MemberId Num 8
> 11. 11. MemberId
> 2 MemberNHPid Char 15
> $15. $15. MemberNHPid
> 4 OfficeClaimid Char 20
> $20. $20. ClaimId
> 5 OfficeVisitDate Num 8 DATETIME
> 22.3 DATETIME22.3 ServiceDateFrom
> 10 OfficeVisitPrimDiag Char 8
> $8. $8. PrimaryDiagnosisCode
> 12 TimeFrame Num 8
>
> Something is definetely wrong if a2.ServiceDateFrom >= a1.AdmitDate does
> not work!!!!!
>
> What I am doing wrong?
> Could you please give me a hand? Thank you in advance,
>
> Irin
>
>
>
>
>
|