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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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