datalines 1ABC 1 1ABC 1 1ABC 1 1ABC 2 1ABC 2 1ABC 2 2KHG 5 2KHG 5 2KHG 5 run * sort the data to ensure reimbursements are tested correctly in next step proc sort data = med1 by id ATC reimb_date run * check if reimbursement occurred in 60 day periods data med2 set med1 by ATC retain reimb_period if first.ATC then reimb_period = 1 else reimb_period + 1 reimb_datdif = datdif(ref_date,reimb_date,'ACT/ACT') reimb_test = reimb_period * 60 if reimb_datdif le reimb_test then success = 1 else if reimb_datdif gt reimb_test then success = 0 run * reshape table data med3 set med2 by id * I assume three reimbursement periods, but changing the _3 to another number will add more retain ATC1_1-ATC1_3 retain ATC2_1-ATC2_3 retain ATC3_1-ATC3_3 retain ATC4_1-ATC4_3 retain ATC5_1-ATC5_3 array ATC1_array ATC1_1-ATC1_3 array ATC2_array ATC2_1-ATC2_3 array ATC3_array ATC3_1-ATC3_3 array ATC4_array ATC4_1-ATC4_3 array ATC5_array ATC5_1-ATC5_3 if first.id then do call missing(of ATC1_array) end if ATC = 1 then ATC1_array = success else if ATC = 2 then ATC2_array = success else if ATC = 3 then ATC3_array = success else if ATC = 4 then ATC4_array = success else if ATC = 5 then ATC5_array = success * try commenting out this last conditional if you have never used this before, it works together with the RETAIN statement above to reshape the table one row at a time if last. 18 Moreover, SkHep-1 cells functionally express particularly well-studied G-protein-coupled receptors in hepatocytes, such as the V1a vasopressin receptor 14, 24 and the purinergic P2Y receptor, 25 as.
* prepare sample data data med1 input id $ ref_date YYMMDD10. This liver cell line was used because, as in primary hepatocytes, it contains Ca 2+-signaling machinery in both the cytoplasm and the nucleus. Note I assumed three periods of 60 days, but you can add more where noted below. With more values of ATC it might become worth it to look into macros, but this should give you the table you are after. Hi Yohann, I used a brute force method so there is a little repetition.
datalines 1 1 01Jan2007 1 2 04Jan2007 1 3 07Jul2008 2 1 15Feb2009 2 2 03Mar2009 2 3 30Mar2010 3 1 20Dec2012 3 2 15Feb2013 4 1 15Feb2009 4 3 30Mar2010 4 3 05Apr2010 run data datediff2 set datediff * I use a new variable to store the start_date argument for datdif() retain date_previous NewQnum2 by study_id if first.study_id then do date_previous = interviewdt NewQnum2=1 end * Here I use the date_previous variable I created earlier as start_date and the current row interviewDt as end_date diff_IntDt = datdif(date_previous,interviewDt,'ACT/ACT') if diff_IntDt < 300 then do output NewQnum2 + 1 end * When I have already output the row, I store the current row in the new variable so it can be used next row date_previous = interviewdt run proc print data=datediff2 run data datediff input study_id qnum interviewdt date9. I used the datdif() function, which is what I think you meant to use, but I had to use another variable to remember the date I'm comparing the interview date to.