Date Range SAS

Reply
Frequent Contributor
Posts: 138

Date Range SAS

Hi I need to write some code in order to create the logic below within the case statement.

Im not sure how the date coding works so any help would be appreciated? 

proc sql;

create table rate as

select *,

case

when Value_Date < today()-365 then tpr, Deal_Int_Rate_pc else 0 end as rate

from adjusted_movement;

quit;

Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: Date Range SAS

Hi,

You might want to investigate base SAS coding, these are fundamental questions you will need for most coding efforts:

proc sql;

    create table rate as

    select      *,

                      case    when Value_Date < today()-365 then Deal_Int_Rate_pc

                                    else 0 end as rate

    from adjusted_movement;

quit;

DOnt know what your trying to acheive with the tpr bit?  Maybe you need another when clause.  Case is:

case <condition>    when <result> then <value> else <value> end

or

case when <condition> then <value> else <value> end

Frequent Contributor
Posts: 138

Re: Date Range SAS

Im trying to replicate what is in excel as a formula

R3 = TPR

K3 = Deal_Int_Rate_pc

=IF(H2<(TODAY()-365),R3,K3)

Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: Date Range SAS

So:

case    when h2_variable < (today()-365) then r3_variable

              else k3_variable end as RESULT

Respected Advisor
Posts: 4,606

Re: Date Range SAS

There should be a single name or expression in each clause of the case expression

case

when Value_Date < today()-365 then tpr else Deal_Int_Rate_pc end as rate

PG

PG
Frequent Contributor
Posts: 138

Re: Date Range SAS

Thanks, works fine now.

Ask a Question
Discussion stats
  • 5 replies
  • 220 views
  • 0 likes
  • 3 in conversation