I am using MYSQL. Basically I am trying to generate a dataset based on my own defined date range. Can someone share how I am able to do a looping like in SAS? example:
%macro date_loop(start,end);
/*converts the dates to SAS dates*/
%let start=%sysfunc(inputn(&start,anydtdte9.));
%let end=%sysfunc(inputn(&end,anydtdte9.));
/*determines the number of months between the two dates*/
%let dif=%sysfunc(intck(month,&start,&end));
%do i=0 %to &dif;
/*advances the date i months from the start date and applys the DATE9. format*/
%let date=%sysfunc(putn(%sysfunc(intnx(month,&start,&i,b)),date9.));
%put &date;
%end;
%mend;
%date_loop(2017-01-31,2019-01-31)
Part of my MySQL code: The st_date is self defined.
SET @st_date = '2019-01-31'
DATE_FORMAT(@st_date,'%d/%m/%Y') as POSITION_DATE,