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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 762 views
  • 0 likes
  • 4 in conversation