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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.