Hello! I am currently working on a problem where I need to filter a data set differently depending on conditions about that table. The program I am writing will be run on a weekly basis and there may be some times it needs to filter in different ways. The table has a date column and a status column. If the max year in the data set is equal to the current year there is a specific way it needs to be filtered, and if it is not equal to the current year there will be a change to the filter. I have tried using if logic with multiple set statements in a data step, and found that is not possible (maybe?). I have also tried proc sql with case when statements and have had no success. Lastly, I have tried using a macro variable, but am inexperienced with working with macros. Here is an example of what I have tried: DATA want;
SET have;
IF MAX(YEAR(have.DATE)) = YEAR(TODAY()) THEN
SET have(WHERE=(have.DATE >= INTNX('Year', have.DATE, 0, 'B') AND have.STATUS = 'Approved'));
ElSE SET have(WHERE=(have.DATE >= INTNX('Year', have.DATE, -1, 'B') AND have.STATUS = 'Approved')); RUN; Essentially, if the max date is in the current year then I need the rows in that year, and if the max date is in the previous year, than I need all of the rows from that year.
... View more