Could you please guide me with the 'case when....' statement or other equivalents in order to align in expression in DI Studio for the following if clauses? I was advised not to use user written transformation. Objective is to create a new variable 'PODVER'
data have;
input renewal_date $ KNKATD;
datalines;
15jun 1
21sep 2
19sep 7
08jan 7
;
run;
data want (drop=current_date);
set have;
current_date=today();
format current_date date9.;
format new_renewal_date date9.;
if (input(cats(renewal_date,"2018"),date9.)<current_date) then new_renewal_date=input(cats(renewal_date,"2019"),date9.);
else new_renewal_date=input(cats(renewal_date,"2018"),date9.);
run;
data want_new;
set want;
format PODVER date9.;
if new_renewal_date='19sep2018'd and KNKATD=7 then PODVER=new_renewal_date+365;
else PODVER=new_renewal_date;
run;
Just going by the if statments, something like this should work:
case when renewal_date="19sep" then "19sep2019"d when input(cats(renewal_date,"2018"),date9.) < today() then input(cats(renewal_date,"2018"),date9.) else input(cats(renewal_date,"2019"),date9.) end
Its quite hard to tell however, as you use today() in a comparison which will obviously change from day to day, not sure what bearing that has on the code
You've not checked the condition for KNKATD=7.
Add it in then, you can copy paste directly the and.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.