Hello
I am trying to create a data set that includes all possible combinations
I get an error "ERROR: Expected %TO not found in %DO statement.
ERROR: A dummy macro will be compiled."
%let date_MinDdate=1701;
%let No=24;
%macro myacro3;
%do i=0 %to &No.;
%do j='a','b';
T_NEHNUT=put(intnx('month',&date_MinDdate.,&i.),yymmn4.)*1;
x =&j.;
output;
%end;
%end;
%mend myacro3;
Data ppp;
%myacro3;
Run;
First step: change all %do and %end statements. Get rid of the percent signs. DATA steps can execute DO loops, so don't complicate life by using macro code instead of DATA step code.
A likely second step: 1701 is a date in the mid 1960s. Consider ways to convert that to the date you want, so you can feed the right date to INTNX.
********************** EDITED:
Having had time to take a second look, there are additional issues to consider as well. Rather than letting them occur one at a time, here's a better approach that addresses all of them:
%let date_MinDdate=1701;
%let No=24;
data ppp;
do i=0 to &no;
T_NEHNUT = 1 * put(
intnx('month', input("20&DateMinDdate.01", yymmdd8.), i),
yymmn4.);
do x='a', 'b';
output;
end;
end;
drop i;
run;
I hope I balanced the the parentheses properly .... it's untested code. But it should be easy enough to tweak if necessary.
The macro %DO loop does not support all of the functionality of the data step DO loop.
But since you don't need macro code it doesn't really matter.
%let date_MinDdate='01Jan2017'd;
%let No=24;
data ppp;
do i=0 to &No.;
do x='a','b';
T_NEHNUT=input(put(intnx('month',&date_MinDdate.,i),yymmn4.),4.);
output;
end;
end;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: