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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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