I am an extremely novice SAS Enterprise user. I have a set of data that includes the dates that patients died as the variable "death date". If a patient has died, the data when this occurred is displayed. If a patient is still alive, the cell is empty. I would like to create a new variable called "alive" with 1 indicating that the patient is still alive and 0 indicating that the patient has passed away. Could someone please help?
I am an extremely novice SAS Enterprise user.
Do you mean SAS Enterprise Guide, or SAS Enterprise Miner? These are not the same.
And do you want code to do this, or do you want to use the menu system in either software to achieve this result?
Code:
if missing(death_date) then alive=1; else alive=0;
Hi @PaigeMiller, thank you for your response. I am using SAS Enterprise Guide. The code is helpful. How would I use the menu system to do this?
I don't know how to do this in the menu system, but I'm sure someone will come along who does know!
I received a syntax error when I tried to use the code. How do I extrapolate the code to all patients? I want to ensure that this variable appears next to the other variables in the file.
A syntax error happened? You need to show us the LOG for this code, otherwise we don't know what error it was. We need to see the entire log for this DATA step or PROC, not selected parts of the log.
Sorry, here is the code.
This is the output that I get - one cell for death_date with the newly created variable of whether the patient is alive. However, this does not appear for all patients and is not inserted into the original datasheet.
So just to be clear, I asked for the entire LOG, not the code. You can't say there was a syntax error, and then not show us the exact error in the log. Just to be clear, I want the entire LOG, not just the errors.
Nevertheless, I am going to skip the explanation here. I think you need to do this through menus, or just take a few steps backwards and learn the basics of how to write data steps and how to use LIBNAMES. That type of beginner learning is best done through some sort of training (and there is plenty available), rather than by someone trying to explain all of this in the forum.
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.