I need to write a code in SAS in order to substitute Access. There's one part of this code that I don't know how to do it due to the difference between Access/SQL and SAS using "if".
While in Access the command "if" doesn't need to create a new variable, in SAS we have to create it.
In Access, the code is something like this:
(IIf(date2 > par_final, par_final, date2) -
IIf(date1 > par_initial, par_initial, date1))/365 as exposure
All the variables are in date format. When I write this in SAS code, I have to create a new variable. For example:
If date2 > par_final then
Field1 = par_final; Else Field1 = date2;
However, I want to create Just the exposure. I don't need to create any other variables.
How can I write this in SAS code?
I thought firstly create the first variable using the if condition and also the Second variable using if after minus. Then I make (field1 - field2)/365 to create exposure and drop field1 and field2.
Could anyone give me a better suggestion? Are there ways to do it without creating those variables?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire