I am quite a beginner and am having real issues with what is probably straightforward.
I need to recode a variable under certain conditions based on what's in other ones.
Specifically, it's like this:
serial RECD RECM RECY INTD INTM INTY
1 77 77 7777 77 77 7777
2 9 9 2008 28 8 2008
3 20 10 2008 99 99 2008
4 77 77 7777 77 77 7777
(sorry for shortened formatting in above table, not sure how to fix!)
REC stands for 'form received date' and INT is 'interview date', D/Y/M is day/month/year
I need to recode INTM (month of interview), only when it is 99, based on what is in RECD and RECM.
If RECD is less than 6, i need to recode INTM to one less than RECM (i.e. if the interview report form was received in the first five days of the month, then set the interview month to the previous month.)
If RECD is 6 or greater, i need to set INTM to the same as RECM (i.e. the interview form was received the same month the interview took place.)
So in the example above, for serial no. 3 i want to recode INTM from 99 to 10, because RECM is 10 and RECD is greater than 5.
I've tried lots of things, but am getting nowhere trying to select INTM=99 and then RECODE under the various conditions. The order of commands and the syntax is getting me confused. Don't even know if i need a RECODE in there or not.
Trying things like:
if (INTM eq 99) and (RECD gt 5).
or something like
if (INTM eq 99) and (RECD gt 5) and (RECM eq 1) INTM eq 1.
But no good.
Any help greatly appreciated!