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!

SAS MACRO Errors...HELP!

Status
Not open for further replies.

needhelpwithsas

Programmer
Sep 29, 2010
2
US
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!
 
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
 
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!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top