Hello Thanks for nice answers. I found the best code that is working well. %let start=1701; %let end=1803; %let date_start=%sysfunc(inputn(&start.,yymmn4.)); %let date_end=%sysfunc(inputn(&end.,yymmn4.)); %put &date_start.; %put &date_end.; Data want_month; do j=0 to intck('month',&date_start.,&date_end.) ; ddate=intnx('month', &date_start., j, 's'); char_ddate = put(ddate, YYMMn4.); /*Var_Macro_name=compress('m'||put(J,2.));*/ Var_Macro_name='m'||strip(put(J,2.)); call symputx('m'||strip(put(J,2.)), char_ddate); output; end; Run; I have 2 other problems: Problem1- I want to calculate number of months between start and end and create a sas macro variable with this value. One way to do it is working well. PROC SQL Noprint; select count(*) INTO:n from want_month ; QUIT; %put &n.; I have tried to do it in open code but didn't succeed %let n=%sysfunc(intck('month',&date_start.,&date_end.)); /*Here we have a problem and we get in log a message: WARNING: An argument to the function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.*/ Problem2- I want to see sas macro varaibles values in log. %put &m0; %put &m1; %put &m2; %put &m3; %put &m4; %put &m14; %PUT &&m&n..; /*Here there is a problem and I don't get value of macro varaible m15*/ /*In log we can see : WARNING: Apparent symbolic reference M not resolved. &m 15.*/
... View more