08-09-2016 02:25 PM
Hello, I am trying to do a report with Month over month% change. Our date field is a numeric field i.e for example has value 20160501. I need to get priormonth same day and compare counts . I am trying to do this in sas enterprise guide. What is the function I should use to get priormonth day value out of this field? Any help is much appreciated
08-09-2016 03:04 PM
Use the INTNX function.
intnx('month', yourVariable, -1, 'same');
will return the same day in the previous month (-1)
Use 'b' or 'e' to return the beginning or end day of the previous month, respectively.
08-09-2016 03:08 PM
08-09-2016 03:45 PM
I'm assuming you're asking how to find the record that is a year before, not just the date.
You need to provide your data structure, what you want as output and ideally, if you're using the GUI in EG or coding.
Please post data as text, NOT as an image.
08-09-2016 03:53 PM
First thing when looking at manipulating dates is to start with a SAS date valued variable. @KurtBremser shows how to convert your number to a SAS date value.
Then you can use a number of SAS functions to either increment a date, INTNX or examine the different number of time periods between two dates (or time or datetimes) with INTCK.
You would likely want to look a a new date of a given interval.
Priormonth = INTNX('month',date,-1,'same');
That says to create a new date value that is one month before the value of date for the same day of the month.
How to compare counts would require much more knowledge about the structure of your current data set and how you are counting. You might be better off posting some example input data and the desired result.
08-09-2016 04:49 PM
Thank you all for your responses !!
I am using GUI in the SAS EG. If I can get the prior month date value then I know how to get the record and do the comparsion...Here is what I have. I have a booking date which is a number and I think the input function posted by KurtBremser I converted to date and the next step was to get prior month same day but I am getting a blank...I am not sure what I am doing wrong.
Thank you for helping me out !!