Ram,
One of the problems of interactive programming is that the system needs
certain signals to proceed. As a beginner you have to learn what the
system is waiting for.
If you start a statement with *, the system will continue to eat code until
it comes to semi-colon signaling the end of the comment. Usually there are
lots of semi-colons, so the program may not work, but there is little
danger. But if you begin with /*, nothing will stop the system from eating
code until the signal */, and there are no messages. %MACRO is command to
start compiling a macro. All code until the signal %MEND will be eaten as
part of this macro.
The message you give indicates that the word "%MEND" was not seen as a
signal and the system is still waiting for the proper signal. In
interactive SAS there are no absolute commands. Context is everything and
macro can make the context much harder to understand.
To get out of this kind of trap, sometimes the "magic string",
*';*";*/;*);run;data w;run;
will work, and produce a message about the data set W. In this case you
can continue. When that doesn't work I try a sequence of %MEND statements
looking for a message that %MEND signal was found without a %MACRO. If
that fails I find it easiest to save work and get out of SAS, and start
over.
To understand the command let's look at the first part *'; If we are at a
statement boundary, it is a comment and harmless. If we are in a single
quoted string, we end the string and try to cause a statement boundary.
The rest of the "magic string" has similar explanations for different
contexts. The code does not handle all situations. For example, perhaps
two or more closing parentheses are needed or maybe the *'; causes a
problem because we are not in a quoted expression and we are not on a
statement boundary. Unfortunately the best order for the "magic string"
depends on knowing what the problem is, but it works often enough to be
worth trying.
If you still have lot's of problems, you might find it better to work with
an editor that allows you to submit batch SAS jobs. When teaching with
version 6.04 (15 years ago) I tried very hard to get students to see the
advantages of interactive processing, but times have changed as computers
have gotten faster and SAS more efficient, so that today the advantages of
interactive development are less clear.
Ian Whitlock
===============
Date: Tue, 18 Oct 2005 09:57:13 -0400
Reply-To: Ram <***@VIRGINIA.EDU>
Sender: "SAS(r) Discussion"
From: Ram <***@VIRGINIA.EDU>
Organization: University of Virginia
Subject: SAS session gets stuck sometimes
Comments: To: sas-l
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi
I am a beginner in SAS. Once in a while, when I do something real
stupid, SAS gets irretrievably stuck. Anything I punch in after that
just appears as text in the log. For example, this error came up one time--
ERROR: Macro keyword MEND appears as text. A semicolon or other
delimiter may be missing.
Is there anything I can do to get out of this mode and back to testing
my code, other than having to close/open SAS session itself. I tried to
look for kill process/job, but found nothing.
thanks,
Ram