BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

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;
3 REPLIES 3
Astounding
PROC Star

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.

 

andreas_lds
Jade | Level 19
If you want combination, use Google or whatever search-site you prefer, there are procedures and functions for such tasks.
Tom
Super User Tom
Super User

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;
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1031 views
  • 0 likes
  • 4 in conversation