troubleshooting Question

How to call macro from one SAS program in another SAS program?

Avatar of labradorchik
labradorchikFlag for United States of America asked on
Unix OSDatabasesProgramming
5 Comments2 Solutions2062 ViewsLast Modified:
How can I call macro from one SAS program in another SAS program?

This is my SAS code with calling macro, which gets a warning "WARNING: Apparent symbolic reference MYMACRO not resolved."  
I thought this is a correct way to call macro. Anyone see a problem with the way I am calling my macro?

DATA testnbrs;
  INFILE 'phonenum.dat' TRUNCOVER;
    INPUT numbs $ 1-10 rcode $ 14-16;
RUN;

PROC PRINT DATA = testnbrs NOOBS;
  WHERE numbs = "&mymacro";
   TITLE "Testing ALL Phone Numbers";
RUN;


Below is the macro SAS code that I am trying to run:
%macro mymacro(numbs,rcode);
  if verify(trim(&numbs),"0123456789") > 0 then
    do;
      &numbs =" ";
      &rcode="1";
    end;

  else if length(trim(&numbs)) ^=10           then
    do;
      &numbs =" ";
      &rcode="1";
    end;

  else if length(substr(&numbs,1,10)) =10  then
    do;
      if verify(trim(&numbs),"0123456789") = 0 then
        do;
          &rcode="0";
        end;

if substr(&numbs,1,1) in ("0","1")        then
        do;
          &numbs =" ";
          &rcode="1";
        end;

      else if substr(&numbs,4,1) in ("0","1")   then
        do;
          &numbs =" ";
          &rcode="1";
        end;

      else if substr(&numbs,2,1)="9"            then
        do;
          &numbs =" ";
          &rcode="1";
        end;

   isame = 1;
      do i = 5 to 10;
        if substr(&numbs,4,1) not = substr(&numbs,i,1) then 
           isame = 0;
      end;

      if isame = 1 then
        do;
          &numbs =" ";
          &rcode="1";
        end;
    end;
%mend mymacro;

Input file phonenum.dat has the following numbers (for testing purposes):
012345678h
0123456789
9876543210
0987654321
0112345678
8876543210
ASKER CERTIFIED SOLUTION
Ian
Statistician

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros