Hi all, i am trying to create a macro which contains a proc sql procedure and returns a number. I would also like to call this macro within another macro.
Here's the macro:
Here's an example of how i'm calling it:
[tt]
When I call the macro, I get the following error:
select count(*) INTO bsLinkage FROM &toDSN T,
------
180
1 ! &fromDSN F WHERE T.&linkVariable = F.&linkVariable; quit; &obsLinkage
ERROR 180-322: Statement is not valid or it is used out of proper order.
[/tt]
I know how this can macro work if I get the macro to return the result to a global variable, but it would be nice to have it as a self contained 'macro function'. Is this possible?
Any help would be much appreciated
Cheers,
Dan
Here's the macro:
Code:
%macro checkJoin(fromDSN, toDSN, linkVariable);
%let obsLinkage = 0;
proc sql noprint;
select count(*)
INTO :obsLinkage
FROM &toDSN T, &fromDSN F
WHERE T.&linkVariable = F.&linkVariable;
quit;
&obsLinkage
%mend checkJoin;
Here's an example of how i'm calling it:
Code:
%macro testIt();
%local theResult;
&theResult = %checkJoin(data2, data1, id);
%put &theResult;
%mend;
When I call the macro, I get the following error:
select count(*) INTO bsLinkage FROM &toDSN T,
------
180
1 ! &fromDSN F WHERE T.&linkVariable = F.&linkVariable; quit; &obsLinkage
ERROR 180-322: Statement is not valid or it is used out of proper order.
[/tt]
I know how this can macro work if I get the macro to return the result to a global variable, but it would be nice to have it as a self contained 'macro function'. Is this possible?
Any help would be much appreciated
Cheers,
Dan