- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to make the following code to be shorter:
If Period = 40 Then Do;
If Years > 20 and Years < 30 Then
Effect_on_Guarantee = 1;
Else Effect_on_Guarantee = Lapse_Multipliers;
End;
Else Effect_on_Guarantee = Lapse_Multipliers;
To achieve this I'm trying to use IFN function like this:
IFN(a.Period = 40, IFN((a.Period > 20 and a.Period < 30),1, Lapse_Multipliers),Lapse_Multipliers) As Effect_on_Guarantee
In This way IFN doesn't return any error or warning but doesn't the work as along version of code does.
Where is a mistake?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@IgorR wrote:
In This way IFN doesn't return any error or warning but doesn't the work as along version of code does.
Where is a mistake?
You have NOT told us what is wrong. Saying it doesn't work gives us no useful information. What do you see that is wrong?
Why do you switch from a variable named YEAR to a variable named PERIOD? Could that be the problem?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Why would you want to convert readable code into a function call?
If it is so you add it to an SQL statement then use CASE clause.
case when (Period = 40) then
case when (Years > 20 and Years < 30) then 1 else Lapse_Multipliers end
else Lapse_Multipliers
end
If you want to reduce the LOGIC of the test then do:
case when ((Period = 40) and (Years > 20 and Years < 30)) then 1
else Lapse_Multipliers
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@IgorR wrote:
In This way IFN doesn't return any error or warning but doesn't the work as along version of code does.
Where is a mistake?
You have NOT told us what is wrong. Saying it doesn't work gives us no useful information. What do you see that is wrong?
Why do you switch from a variable named YEAR to a variable named PERIOD? Could that be the problem?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What a silly mistake.
The problem indeed in switching Years to Period.
Now I fixed it and it works.