BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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