BookmarkSubscribeRSS Feed
kfluegge
Fluorite | Level 6

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;
3 REPLIES 3
Astounding
PROC Star

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.

ballardw
Super User

@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.

SuryaKiran
Meteorite | Level 14

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.

 

 

Thanks,
Suryakiran

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1073 views
  • 0 likes
  • 4 in conversation