Using the sample code above, how do I simulate survival data using certain specifications such as:
My SAS skills are very rusty as I have not used it in over a year now. Any help would be greatly appreciated.
Please do not post images of your code or question. It makes it harder to comment and modify it, unless I type it all out.
Regarding 1/2, line 5/6 of the code controls that. Look up the exponential randexp function to see how to set it with a specified mean. You probably want to switch to using the RAND() function instead which allows you to do this more easily.
Regarding 3, look at line 4 of the code. What happens if you run the code as is. And then what happens when you change it and run it again?
@Buchholz91 wrote:
Using the sample code above, how do I simulate survival data using certain specifications such as:
My SAS skills are very rusty as I have not used it in over a year now. Any help would be greatly appreciated.
data survData;
lambdat = 0.02; *baseline hazard;
lambdac = 0.04; *censoring hazard;
do i = 1 to 100;
t = RANEXP(12345)/lambdat; * time of event;
c = RANEXP(67890)/lambdac; * time of censoring;
time = min(t, c); * which happens first?;
censored = (c < t); * censored when the censoring hapapened before event;
output;
end;
drop i lambda:;
run;
proc freq data=SurvData;
tables censored ;
run;
proc univariate data=survData;
histogram T C;
run;
Above is the sample code that I have and below are a few questions. This is the same code & questions from earlier, but now they are copy and pasted instead of images.
simulate a survival data with the following specifications:
What's the expected value for an exponential distribution in relation to your parameter? That's a statistics question, not a programming question 🙂
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.