Generating pseudo event dates for control group

Reply
Occasional Contributor
Posts: 8

Generating pseudo event dates for control group

Hi,

 

I am doing a retrospective case control study. I have the case cohort with ptid, and index event date. The study period is fix.

I have the control cohort with only ptid.

 

I want to generate and randomly assign the index event date for patients in control cohort by simulating the distribution of index event dates of patients in the case cohort.

 

How can i do that? I tried differnt versions of ranuni function but so far all the methods i have explored require some kind of anchoor date to compute the difference between anchor date and index event date, which i do not have. 

 

Any help is greatly appreciated.

 

Thank you!

Rupali

Super User
Posts: 19,799

Re: Generating pseudo event dates for control group

It depends a bit on your data structure which you haven't provided and if duplicates are allowed.

 

One way is to us the RANTBL function with all the values of your event dates. A second is to take your event table, sort it randomly and then merge it back with your original table. Both are relatively straightforward to code in a data step.

 

RANTBL()

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000127844.htm

You may want the CALL RANTBL() routine instead.

 

You can create the list of dates using a macro variable, again depending on how big your dataset is, the code below is untested but should give you the idea. 

 

proc sql; 
select event_dates into :date_list separated by ", "
from have;
quit;

Data want;
set have;

date_random = rantbl(234, &date_list);

run;
Ask a Question
Discussion stats
  • 1 reply
  • 266 views
  • 0 likes
  • 2 in conversation