03-21-2013 07:03 PM
first_day=intnx('Month', TODAY(), &n, 'begin');
call symput('start', first_day);
where my_ date =&start;
find_it(n=-2) /*pulls January 2013*/
find_it(n=-1)/*pulls February 2013*/
find_it(n=0)/*pulls March 2013*/
This is a snippet of a program that pulls 30 days of data based on my_date in 3 separate spreadsheets. What I want to do is a 60 day spreadsheet that pulls in February and March in one spreadsheet and December and January in another and advance through the year which will mean less spreadsheets. Each time this runs it produces three separate spreadsheets based on each month. I believe I must alter the first_day code first_day=intnx('Month', TODAY(), &n, 'begin'); but not sure how to get it to pull 60 days worth instead of 30 days. in
03-22-2013 09:32 AM
Here is the code. I tried the month2
%MACRO FPD_IT (n=);
FirstDay=intnx('month2', TODAY(), &n, 'beginning');
CALL SYMPUT('StartDate', FirstDay);
CALL SYMPUT('StartDateMMMYY', PUT( FirstDay,EURDFMY5.));
CALL SYMPUT('StartDateMonth', PUT( FirstDay,EURDFMN3.));
CALL SYMPUT('StartDateYear', PUT( FirstDay,YEAR2.));
%FPD_IT (n=-2);/*produces 30 day report for January*/
%FPD_IT (n=-1);/*produces 30 day report for February*/
%FPD_IT (n=0); /*produces 30 day report for March*/
The objective is to combine n=0 and n=-1 into one report to get a 60 day report. What I am getting are separate 30 day reports
03-22-2013 09:44 AM
The problem is with your data. It looks like you already have a variable named MY_DATE that takes on unique values for a 30-day period. You will need a different WHERE statement to select the proper observations.
I would suggest one, but it's probably wrong, such as:
where my_date in (&start, intnx('month', &start, +1));
There are too many complications. For example, does "30-day" really mean 30 days, or does it mean a calendar month? Can you have a value for MY_DATE that is not the first day of a month?
At any rate, the WHERE statement performs the subsetting. That's the statement that needs to be modified.
03-22-2013 09:54 AM
I don't understand. I thought you asked "how to I look back in increments of 2 months?". That is what MONTH2 does.
Then you ask "the objective...." question that seems to be answered by MONTH2 n=-1.
You will have to show your work.