Hi. I have the if then statement below. "Disch" is a date variable (format YYYY-MM-DD). When running the code, the DEATH variable is blank even for records where the value of ddest = 20. I wish for the DEATH variable to be populated with the DISCH date when ddest = 20. This seems like it should be quite simple, but apparently I do not know how to do it.
if ddest = 20 then disch = DEATH;
It looks like you got it backwards:
if ddest = 20 then DEATH = disch;
It's a good idea to read the notes on the log. You should have seen something like this:
NOTE: The variable death is uninitialized.
That's SAS's way of saying that it doesn't exist so you can't copy from it.
@Astounding wrote:
It looks like you got it backwards:
if ddest = 20 then DEATH = disch;
It's a good idea to read the notes on the log. You should have seen something like this:
NOTE: The variable death is uninitialized.
That's SAS's way of saying that it doesn't exist so you can't copy from it.
And you likely want to make sure that you have a date format of some type assigned to the DEATH variable if disch is a SAS date valued variable.
Does your source data have same datatypes for both of the variables disch & death. From what you explained it must be death=disch instead of the opposite way.
If they are of different datatypes then create a new variable or rename death from source dataset and create death in new dataset.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.