BookmarkSubscribeRSS Feed
lillymaginta1
Obsidian | Level 7
data have;
infile cards ;
input ID drug interval   (first_Date drug_Date) (: mmddyy10.) ;	 
cards;
001 1  4 1/1/2004  1/5/2004
002 1 5 4/5/2004  4/10/2004
003 1 14 6/1/2005 6/15/2009
004 0 .    1/4/2010     . 
005 0 .    4/5/2010     . 
006 0 .    6/5/2010     .
;

I have data with two groups: a) treatment group with first date and drug_Date, and b)control group with first_Date only. I want to create drug_date in the control group based on the interval variable which equal drug_Date- first_Date. 

An example output for the control group (where drug=0)

004 0 4 1/4/2010 1/8/2010 005 0 5 4/5/2010 4/10/2010 006 0 14 6/5/2010 6/19/2010

4 REPLIES 4
PaigeMiller
Diamond | Level 26

I'm not sure how you intend to do this. Does line 1 match with line 4? Or not?

 

Can you walk us through the steps you have in mind in words (instead of using SAS code)?

--
Paige Miller
lillymaginta1
Obsidian | Level 7
001 1  4 1/1/2004  1/5/2004
002 1 5 4/5/2004  4/10/2004
003 1 14 6/1/2005 6/15/2009
004 0 .    1/4/2010     . 
005 0 .    4/5/2010     . 
006 0 .    6/5/2010     .

The difference between line 1 and line 4 is that each one correspond to a different treatment group.

Here is a hypothetical steps:

1) Patient in drug=0 group (example patient 4) first_Date is within the same month and year of a patient in drug=1 group.

2) if step 1 is correct, then randomly select one patient from drug=1 who met the criteria 

3) generate drug_Date based on the interval between drug_Date and first_date of the patient selected in step 2 (example patient 3 was selected for patient 4, then the interval= 4)

4) output for patient 4 would be 6/5/2010 + 14= 6/19/2010  

PaigeMiller
Diamond | Level 26

@lillymaginta1 wrote:

2) if step 1 is correct, then randomly select one patient from drug=1 who met the criteria 


What does this mean? How would I know if it is correct? What does "correct" mean in this context?

 

 

1) Patient in drug=0 group (example patient 4) first_Date is within the same month and year of a patient in drug=1 group.

 

What happens if there are no matches? What happens if there are multiple matches?

--
Paige Miller
lillymaginta1
Obsidian | Level 7

Sorry for the confusion, if the condition applies (not correct) then randomly pick one of the multiple matches from the drug=1 group and generate the date. 

If there are no matches, I think generating a drug_Date based on the mean (interval) of all patient in drug=1 group should be fine. 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1163 views
  • 2 likes
  • 2 in conversation