×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SAS MACRO Errors...HELP!

SAS MACRO Errors...HELP!

SAS MACRO Errors...HELP!

(OP)
I am working on a program delivered as PC SAS and have converted it to work on the mainframe.  There are 4 macros in the program for 4 time periods.  Depending on the quarter I am reporting on I call each one.  The program was delievered with this within a data step

%callqtr&QTR.;

&QTR is defined as 4 (in this case) and input via a parm card.  When I process the program with a hard coded 4 it works.

%callqtr4;

But when I use the symbolic as part of the macro name it does not.  I am now trying this...

If QTR = 1 then do;
   %callqtr1;
end;
If QTR = 2 then do;
   %callqtr2;
end;

etc...
I get this error
ERROR 117-185: There was 1 unclosed DO block.
ERROR 117-185: There was 1 unclosed DO block.
ERROR 117-185: There was 1 unclosed DO block.

Any suggestions?  I am new to SAS and this is driving me crazy!  Also due for production and I dont want to move it with hard values.
Thanks for any help you can give!  

RE: SAS MACRO Errors...HELP!

It seems from your description that the parm card value you pass to the macro variable named QTR is resolving too late. You need to have the QTR value set before the macro call executes.

Perhaps if you copy the code and place it on here we can let you know how to modify the program.

Klaz

RE: SAS MACRO Errors...HELP!

(OP)
Here is a stripped version of the code that works.

   OPTIONS MISSING = ' ' OBS=MAX SYMBOLGEN SPOOL;         
%MACRO CREATEM;                                           
 DATA PARMFILE ;                                          
 INFILE PARMFILE LRECL = 80 PAD;                          
 INPUT  FY      $    1 -  4                               
        CY      $    6 -  9                               
        YY      $   11 - 12                               
        MONA    $   14 - 15                               
        MONB    $   17 - 18                               
        MONC    $   20 - 21                               
        Q       $   23      ;                             
        CALL SYMPUT ('FY',TRIM(FY));                      
        CALL SYMPUT ('CY',TRIM(CY));                      
        CALL SYMPUT ('YY',TRIM(YY));                      
        CALL SYMPUT ('MONA',TRIM(MONA));                  
        CALL SYMPUT ('MONB',TRIM(MONB));                  
        CALL SYMPUT ('MONC',TRIM(MONC));                  
        CALL SYMPUT ('Q',TRIM(Q));                        
        RUN;                                          
                                                      
%MACRO QUARTERIS1;                                    
      PUT 'GOT TO QUARTERIS1';   
RUN ;                            
%MEND;                           
                                 
%MACRO QUARTERIS2;               
      PUT 'GOT TO QUARTERIS2';   
RUN ;                            
%MEND;                           
                                 
%MACRO QUARTERIS3;               
      PUT 'GOT TO QUARTERIS3';   
RUN ;                            
%MEND;                           
                                 
%MACRO QUARTERIS4;               
      PUT 'GOT TO QUARTERIS3';   
RUN ;                                         
%MEND;                                        
                                              
DATA COMBO;                                   
INFILE OLDSFMON;                              
   INPUT   FIPS       RPTM_MM     STRATUM     
RUN ;                                         
                                              
DATA SUMRPT;                                  
   SET COMBO;                                 
      BY FIPS RPTM_MM STRATUM ;               
FILE OUT02;                                   
CURRENT = TODAY ( ) ;                         
PUT @01 "REPORT2 STUFF" ;                     
RUN ;                                         
                                              
PROC SUMMARY DATA= COMBO;                     
   CLASS FIPS RPTM_MM ;                       
    VAR STRATUM ;                             
   OUTPUT OUT = STATS2        
          SUM =  STRATUM ;    
RUN ;                         
                              
DATA ALLSUMFL;                
   SET STATS2 ;               
      BY FIPS RPTM_MM;        
                              
      %QUARTERIS4;            
     RUN;                     
                              
DATA QTRPRTFL ;               
FILE OUT01 ;                  
   SET SUMRPT ;               
PUT  @01 "REPORT STUFF" ;     
   RUN ;                      
 %MEND;                       
                              
%CREATEM ;                    
         
 QUIT;   


The program has 4 macros called quarteris1, quarteris2, quarteris3 and quarteris4.  The copy above is executing quarteris4.  I need to modify the code so it can be executed for any quarter by way of the parmfile.  In the parmfile the variable Q is the quarter number.  I need to be able to call the macro with the variable as part of its name ie...  %QUARTERIS&Q;
of using a condition check  like this (psuedo)
if Q = 4 then execute %QUARTERIS4
else
If Q = 3 then execute %QUARTERIS3
else
IF Q = 2 then execute %QUARTERIS2
else
if Q = 1 then execute %QUARTERIS1
end etc.

The hard coded macro name in the code at top works with a good cond code.  If I try to change using the variable Q as part of the macro name it gets an 8 and also when i try using a condition to execute one of the 4 macros it gets an 8.  Any help would be appreciated!
Thanks!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close