do loop like sas

kaweng88 posted 3 months ago in General

Hello all, new user to MySQL here. Previously with SAS one can generate data by looping a date range, can MySQL do the same?

Appreciate everyones help!

if in SAS will be as follows:

%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;


Please login to leave a reply, or register at first.