Hi guys I have the following register-based dataset. It offers information about parents employment history (e.g. y_1452 is week 52 in 2014, etc.) What I need to do is to set this employment data in relation to the birth of a child. pnr week of child-birth (for children born in 2015) y_1452 y_1501 y_1502 y_1503 y_1504 X 1 Y 2 So for example when a child is born in the first week of 2015 week_0 must be equal to y_1501 and week_1 must be equal to y_1502 and so on and soforth. This means that the data-set above have to look something like this: pnr birth week_prior to birth week_0 week_1 week_2 week_3 week_4 X 1 value of y_1452 value of y_1501 value of y_1502 value of y_1503 value of y_1504 value of y_1505 Y 2 value of y_1501 value of y_1502 value of y_1503 value of y_1504 value of y_1505 value of y_1506 I am rather new to SAS so what i have tried so far is to use the rename-function, so for example for children born in the first week of 2015 i have written the following code: data want;
set have;
if week=1;
rename y_1452-y_1401 = week__1 - week__52;
rename y_1501-y_1553 = week_0 - week_52;
rename y_1601-1651 = week_53-week_103;
run; where_ is after birth and __ is before birth. Maybe a bad naming convention btw. So I can potentially do this for the 53 weeks in 2015, and after that merge the datasets. However, it is a lot of work, so maybe any of you have a smart solution? Thanks in advance. Best regards Rasmus Thomsen
... View more