BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
desireatem
Pyrite | Level 9

Hello, in the following data generation; I want to change the last observation for variable 'censored' to '0' when ever it is '1'. That is the 100th observation should have censored=0 , even if it is supposed to e 1

data test;

seed=-1;

  alpha1 = 2.50;

  beta1 = 9.50;

  do i = 1 to 100;

   lambdaT = 0.025; *baseline hazard;

   lambdaC= .03*light=0.15; *heavy=0.03;

   er=0+sqrt(0.0001)*rannor(1);

    t = rand("WEIBULL", 0.75, lambdaT);  * time of event;

    c = rand("WEIBULL", 1.25, lambdaC) ;* time of censoring;

    time = min(t, c);    * which came first?;

    censored = (c lt t);

      obs=(t lt c); * creating observation variable from censored when

      y= alpha1 + beta1*t + er;

    output;

  end;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

data test;

seed=-1;

  alpha1 = 2.50;

  beta1 = 9.50;

  do i = 1 to 100;

   lambdaT = 0.025; *baseline hazard;

   lambdaC= .03;  *light=0.15; *heavy=0.03;

   er=0+sqrt(0.0001)*rannor(1);

    t = rand("WEIBULL", 0.75, lambdaT);  * time of event;

    c = rand("WEIBULL", 1.25, lambdaC) ;* time of censoring;

    time = min(t, c);    * which came first?;

    censored =ifn(i ne 100,(c lt t),0);

      obs=(t lt c); * creating observation variable from censored when

      y= alpha1 + beta1*t + er;

    output;

  end;

run;

View solution in original post

1 REPLY 1
Linlin
Lapis Lazuli | Level 10

data test;

seed=-1;

  alpha1 = 2.50;

  beta1 = 9.50;

  do i = 1 to 100;

   lambdaT = 0.025; *baseline hazard;

   lambdaC= .03;  *light=0.15; *heavy=0.03;

   er=0+sqrt(0.0001)*rannor(1);

    t = rand("WEIBULL", 0.75, lambdaT);  * time of event;

    c = rand("WEIBULL", 1.25, lambdaC) ;* time of censoring;

    time = min(t, c);    * which came first?;

    censored =ifn(i ne 100,(c lt t),0);

      obs=(t lt c); * creating observation variable from censored when

      y= alpha1 + beta1*t + er;

    output;

  end;

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 1 reply
  • 341 views
  • 0 likes
  • 2 in conversation