Hello. I hope everyone is doing well on this fine Monday.
I am attempting to have SAS look at a date variable, Interview_Date, and use this date to mark a period of 5 weeks before the date as missing for employment.
Currently, my data looks like this:
data IntAge;
infile datalines dsd truncover;
input PID R1482600. E0011401-E0013632 Key_Sex_1997 DOB Interview_Date AgeAtInterview;
datalines;
1 4 5232 5232 5232 2 09/1981 07/1997 15
1 4 5232 5232 5232 2 09/1981 11/1997 17
....
....
....
1 4 5232 5232 5232 2 09/1981 01/2016 34
2 7 6654 . . 1 07/1982 05/1997 14
2 7 . 8987 8987 1 07/1982 11/1998 16
;;;;
PID is participant ID.
R1482600 is the participant's ethnicity
E0011401-E0013632 are a set of variables where E0011401 is the first week of 1994 running 52 weeks of that year all the way through E0013632 which is week 32 of 2016. If someone is employed, the have the company code which can be seen on PID 1 with the code 5232.
For instance, PID 1 was hired at the same company for the first 3 weeks of 1994. Their first interview was at 07/1997. I would like to make her employment data for weeks 19-24 (4th week of 05/1997 through 07/1997) missing, .N. I coded all dates to be on the 1st of each month. I did not include all of the employment variables.
As you can see, the data is in wide format. What I am attempting to do is to have SAS read the interview date and then mark any of the employment variables for 5 weeks prior as a special missing, .N.
I am not sure how to accomplish this, but my initial thoughts were to create a reference table with PID and interview date. Reference this table saying that PID has to be in this reference table and when it reads DateofInterview, call the previous five observations missing.
I really need help firming up my logic on how to tackle this task. I have seen others create a flag for the date variable which might work here. Any help would be appreciated.
1. You code does not run.
2. Please provide a sample output for your sample input.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: