- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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:
- Event time T follows an exponential distribution with a mean of 40
- Censoring time Tc follows an exponential distribution with a mean of 25
- Generate 500 observations, with censoring flag indicating whether censoring happened before events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Currently trying to reintroduce myself to SAS after some time off and applying it in this way which I have not done before.
The code shown is still the same as before.
I'm assuming that I change the i = 1 to 100 to become i = 1 to 500 since I want to generate 500 observations.
Still trying to figure out how to specify a mean of 40.
I see that the Exponential Distribution is variable = RAND('Exponential', <sigma>).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What's the expected value for an exponential distribution in relation to your parameter? That's a statistics question, not a programming question 🙂