Date: Fri, 9 Aug 1996 21:41:00 GMT
Reply-To: Richard Dickinson <R-Dickinson@TAMU.EDU>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Richard Dickinson <R-Dickinson@TAMU.EDU>
Organization: Texas A&M University
Subject: Followup question on string count
Several weeks ago I posed a datastep question on the list and
received many good responses to my problem. I've got a new one
now that is related to the original.
Take the following code (which helpful folks on the list
%LET FINDSTR = "NEWVAR";
LENGTH CODE CCODE $ 60;
INPUT @1 CODE $CHAR60.;
DO WHILE (I>0);
COUNT + 1;
KEEP CODE COUNT;
IF NEWVAR=1 THEN NEWVAR=2;
IF NEWVAR=1 THEN
IF NEWVAR=1 THEN A=1; IF NEWVAR=2 THEN A=2;
The above code will count the occurances of "NEWVAR" for each
line of input (2 for line 1, 1 for line 2, 1 for line 3, and 2
for line 4).
What I would rather the code do is count the
occurances of "NEWVAR" in a statement boundary (keep counting
"NEWVAR" until it hits a simicolon, at which time count gets
reset to zero). In other words, I want it to count the
occurances of "NEWVAR" until it hits a simicolon, even if it has
to go to a new line.
So for the above input lines, count would be:
2 for line 1, 1 for line 2, 2 for line 3, and 1 for line 4 (the
count for "NEWVAR" got reset because of the simicolon).
Any help would be appreciated.