Hi Everybody,    I need help separating two variables on a monthly basis.     Specifically, I have data on patients admitted to hospitals. The four variables are:    d_in: The date the patient was admitted to the hospital    d_out: The date the patient was released from the hospital    t_stay: The total number of days the patient stayed at the hospital    t_cost: The total cost of the stay.    I need a way to get the t_stay and t_cost separated by month; for example, if a patient was admitted to the hospital from the 20 th  of april to the 10 th  of may and the total cost was $200, I would get the values stay_april=10, stay_may=10, cost_april=100 and cost_may=100.    If the patient is admitted and released the same month, it is easy, since I can extract the month of the start and the month of the end, check with an if-statement if they are the same, and if they are, I have the values I need directly from the t_stay and t_cost variables.    But I'm having trouble figuring out how to do this with patients whose stay span several months? I hope my question makes sense and I will be grateful for any help.   
						
					
					... View more