BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jenim514
Pyrite | Level 9

Hi all,  I need a little help with a macro.  I basically need the below code to repeat exactly for the 9 treatment groups to create a dummy shell.  I then the output from each treatment group to 'stack' as to create a large shell  with 31 observations output from each treatment group.  The away this is currently written, I am only getting output from group 'T" (the last entered group).

 

Help is appreciated!

 

 

%macro dummy (tx);
data dummy ;
do tx="&tx";
	do ord=11 to 41;
		if ord=11 then do;
		do sord=1 to 2 ;
		output;
		end;
		end;
	if ord=21 then do;
		do sord=1 to 8;
		output;
		end;
		end;

	if ord=31 then do;
		do sord=1 to 12;
		output;
		end;
		end;
	if ord=41 then do;
		do sord=1 to 9;
		output;
		end;
		end;
	end;
end;
run;
%mend dummy;
%dummy (A);
%dummy (B);
%dummy (C);
%dummy (D);
%dummy (E);
%dummy (F);
%dummy (G);
%dummy (H);
%dummy(T);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

To get your program to work, get rid of the macro language.  Take this statement:

 

do tx="&tx";

 

Change it to:

 

do tx = 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'T';

 

Then you can get rid of everything that is macro-related and be left with a DATA step.

 

As it stands now, each time you call the macro, you replace the data set DUMMY.  That seems like the wrong thing to do.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

To get your program to work, get rid of the macro language.  Take this statement:

 

do tx="&tx";

 

Change it to:

 

do tx = 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'T';

 

Then you can get rid of everything that is macro-related and be left with a DATA step.

 

As it stands now, each time you call the macro, you replace the data set DUMMY.  That seems like the wrong thing to do.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 2 replies
  • 891 views
  • 0 likes
  • 2 in conversation