hi,
i'd like to increase a variable (payday) + 1 while it isn't a working day
how can i do something like that, using while and sql?
e.g:
create table new_payday as select
(while payday in ((select holiday from holiday_table),weekday(1),weekday(7)) then payday+1) as payday
from old_payday;
quit;
thanks
Not sure, but I think you are trying something like this
create table new_payday as
select
case when weekday(datepart(payday)) in (1,7) then payday+1 else payday end as payday
from old_payday;
quit;
If it was Saturday that would make the payday Sunday so that logic doesn't make sense for most businesses I know....
Look up the intnx function with the weekday option.
You can also create custom intervals to include your holidays, there's a few posts on here that cover how to do that.
i need to compare with some holidays on my holiday_table
A bit of a long read, but worth it, the very last example is what I'm referring to:
tomorrow im going to test it :smileygrin:
i can only test at job.....thanks
is there a way of using "while" inside proc sql?
I think you're looking for where instead. I'm not familiar with while in SQL though it's getting rusty...
However the intervalds option methodology with customized dataset would render that requirement for this question moot.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.