BookmarkSubscribeRSS Feed

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;

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

Im trying to replicate what is in excel as a formula

R3 = TPR

K3 = Deal_Int_Rate_pc

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

So:

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

              else k3_variable end as RESULT

PGStats
Opal | Level 21

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

Thanks, works fine now.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 896 views
  • 0 likes
  • 3 in conversation