New, and slightly reluctant, SAS user (previously STATA user)
SAS dates have me scratching my head a bit. I have a longitudinal dataset, but I am currently only interested in baseline (e.g. first questionnaire) data for which I have created a new dataset.
Variables:
(a) Date of Baseline Questionnaire: var1 = DDMMYYYY (SAS Informat: DDMMYYYY8)
(b) Known Disease Exposure?: var2: yes(1), no(0), don'tknow(88), refused(99) --> ONLY those that responded YES had the next question asked:
(c) Date of Disease Exposure: var3 = MM (0-12, 0=unknown, 1=January etc.), var4 = YYYY
Goal:
Determine "Time Since Exposure" from baseline questionnaire
What I'd like to do/think I should be doing:
1. Only analyse those individuals at baseline who responded "YES(1)" to var2
2. Assign/impute the middle of each month (e.g. 15th day) as a new variable to every individual (create: var5)
3. Create a new variable: 'DateExp' (var6) -- this will combine var3-5 in to a single variable represented as: DDMMYYY (equivalent to: var5-var3-var4)
- I believe I need to use the MDY function; but the SAS examples are not easily understood (again, being a new user!)
4. Calculate time since exposure (TimeSinceExp=var2-var6/365.25) with an output in Years, rounded to a single decimal (e.g. 5.4 years)
Any assistance would be appreciated. I am pondering this away today and will check in tomorrow to see how close (or far off!) my own code is....so far about 20% of my more complicated coding works (which I would say isn't too bad for 2nd week of use).
Best & many thanks in advance.
-Tyler