02-02-2017 08:15 AM
i am trying to use a variable from a data sent in an INTNX statement to create a new variable in the same dataset. I would like to use the variable 'XXX' to replace the '-12' in the intnx statement below. XXX is a numeric and represents a number of months, i.e 12 months, 18 months, 255 months, etc. My goal is to create a new date variable, which = 'date' - XXX months.
As ever, thanks in advnce to all,
create table test2 as
intnx('Month',date,-12,'s') format=date9. as new_var
02-02-2017 08:54 AM
It depends on whether XXX takes on only positive values, and whether you want to move back or move forward. At any rate, this should probably be the replacement for DATE:
But if that moves you in the wrong direction, use xxx instead.
02-02-2017 09:06 AM
Hi Astounding, thanks for getting backto me.
I dont think I have explained myself well...
'Date' is the date i wish to count back in time from.
'XXX' is a variable - the number of months i want to count back from 'Date'
How do i get the variable 'XXX' to replace the '-12' in this - intnx('Month',date,-12,'s') format=date9. as test
does that make sense?
Need further help from the community? Please ask a new question.