Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to repeat macro in dataset?

Status
Not open for further replies.

on818come

Programmer
Oct 6, 2008
22
US
%macro merge;
DATA sample.export1;
if &TestProp NE 100
then %clipboard;
Run;

PROC APPEND BASE=sample.export1 DATA=sample.export FORCE;
run;

%mend merge;
%merge

What I'm doing is merging several tables ( from 2 to 5)into a summary sheet. Each time get new list of observations from a clipboard procdure, and append to the summary sheet.
Is it possible to be done like this? The above code is not complete. I 'm not very familiar with macro.
Thanks for advicing.
Another question: is there some kind of statement like GOTO in SAS?
 
I'm really confused about macro and data step in SAS.
Can I do like this?

%macro append;
DATA sample.export1;
if &TestProp NE 100
then %clipboard;
Run;

PROC APPEND BASE=sample.export1 DATA=sample.export1 FORCE;
run;

%mend append;


%macro merge;

x=4;
ulabel:x=x-1;
%append
if x GT 1 then
goto ulabel;

%mend merge;
%merge
 
Hiya,
One problem you've got is that you're appending the dataset sample.export1 to itself which I don't think you can do, and is almost certainly not what you WANT to do.

If I understand this correctly, you want to

1 - Get records by running a macro %CLIPBOARD
2 - Get more records from %CLIPBOARD
3 - Append new records to those collected so far
4 - Repeat steps 2 and 3 X number of times where X is 2-5.

If not, can you lay out in a similar fashion to above what it is you want to do? That's the best way to do it, then you write the code to do the steps once through, then construct the loop to iterate the parts that you need to iterate.


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top