Date: Tue, 15 Apr 2003 13:09:38 -0700
Reply-To: Prasad S Ravi <prasad.s.ravi@HOUSEHOLD.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Prasad S Ravi <prasad.s.ravi@HOUSEHOLD.COM>
Subject: Re: SV: SV: Finding rows where grading can be cancelled
Content-type: text/plain; charset=us-ascii
Use INTNX function
avgrad_time=intnx('year',bdato,input(avgradering,2.));
Prasad Ravi
Rune Runnesto
<rune@fastlane.no> To: <prasad.s.ravi@household.com>, <rune@fastlane.no>
cc: <SAS-L@LISTSERV.UGA.EDU>
04/15/2003 12:07 PM Subject: SV: SV: Finding rows where grading can be cancelled
Please respond to
rune
The variable Avgradering is a character variable and can have the values
'2', '5', '30' or ' '.
The variable Bdato is a numeric variable. Bdato and Avgradering do not have
the same format.
How can I make Avgrad_time = 1999-10-04 when Bdato=1994-10-04 and
Avgradering = '5' ?
Rune Runnestoe
-----Opprinnelig melding-----
Fra: Prasad S Ravi [mailto:prasad.s.ravi@household.com]
Sendt: 15. april 2003 20:46
Til: rune@fastlane.no
Kopi: 'Rune Runnestoe'; SAS-L@LISTSERV.UGA.EDU
Emne: Re: SV: Finding rows where grading can be cancelled
I gave you the hint to do it in PROC SQL, convert the vars accordingly.
Read through the ERROR messages and fix the appropriate vars.
Prasad Ravi
Rune Runnesto
<rune@fastlane.no> To:
<prasad.s.ravi@household.com>, "'Rune Runnestoe'" <rune@FASTLANE.NO>
cc:
<SAS-L@LISTSERV.UGA.EDU>
04/15/2003 11:29 AM Subject: SV: Finding rows
where grading can be cancelled
Please respond to
rune
It didn't work, here is what the log says:
85 proc sql;
86 title "Review of documents where grading for security can be
canceled";
87 select Grad,
88 Saksnr,
89 Doknr,
90 Bdato,
91 Avgradering,
92 (Bdato + Avgradering) as Avgrad_time
93 from konkurr.dok1
94 where Grad is not null
95 and Avgradering in ('2','5','30',' ')
96 and calculated Avgrad_time < sysdate( );
ERROR: Expression using addition (+) requires numeric types.
ERROR: Function SYSDATE could not be located.
ERROR: Expression using less than (<) has components that are of different
data types.
Do you have any further suggestions ?
Sincerely
Rune Runnestoe
-----Opprinnelig melding-----
Fra: Prasad S Ravi [mailto:prasad.s.ravi@household.com]
Sendt: 15. april 2003 18:42
Til: Rune Runnestoe
Kopi: SAS-L@LISTSERV.UGA.EDU
Emne: Re: Finding rows where grading can be cancelled
Rune:
Try this and see if it works.
proc sql;
title "Review of documents where grading for security can be canceled";
select Grad,
Saksnr,
Doknr,
Bdato,
Avgradering,
(Bdato + Avgradering) as Avgrad_time
from test.dok1
where Grad is not null
and Avgradering in ('2','5','30',' ')
and calculated Avgrad_time < sysdate( );
Prasad Ravi
Rune Runnestoe
<rune@FASTLANE.NO> To:
SAS-L@LISTSERV.UGA.EDU
Sent by: "SAS(r) cc:
Discussion" Subject: Finding rows where
grading can be cancelled
<SAS-L@LISTSERV.UGA.E
DU>
04/15/2003 06:38 AM
Please respond to
Rune Runnestoe
I read a datafile into a SAS dataset by using this code:
filename 'path\DOK1.txt';
data konkurr.dok1;
infile dok_1 lrecl =28;
input @1 Posttype $1.
@2 Grad $3.
@5 Saksnr $10.
@15 Doknr 3.
@18 Bdato yymmdd8.
@26 Avgradering $3.
format Bdato yymmdd10.
run;
Then I try to identify rows where grading for security has been done,
but where it really should'n be done.
proc sql;
title "Review of documents where grading for security can be canceled";
select Grad,
Saksnr,
Doknr,
Bdato,
Avgradering,
Avgrad_time
from test.dok1
where Grad is not null
and Avgradering in ('2','5','30',' ')
and Avgrad_time < sysdate( );
/*
Avgrad_time is Bdato + Avgradering.
For example in Saksnr 1994/20008, doknr. 6, which has Bdato=1994-10-04,
and Avgradering 5 (years), then Avgrad_time = 1999-10-04.
*/
How do I write the code for declaring the variable Avgrad_time ?
Can this task be more easily resolved using the datastep rather than
proc sql ?
Sincerely
Rune Runnestoe