Hello:
I got an error from the program below, how to fix it?
data datain;
format name $ 500.;
input name &;
cards;
John__If_True_kary
John_If_True__Mary
John__If_True1_kary
John_If_True_kary
Tom__If_Not__Carol
Tom__If_Not_Carol
Tom_If_Not1_Carol
Joe__If_True___Jane
Joe__If_False_Jane
Joe__If_False__Paul1
Joe__If_False___Jane
Paul_If_False2__Jane
Joe__If_False2___Jane
Joe___If_False__Jane
;
run;
data dataout;
set datain;
if prxmatch("m/If_True|mary/i",name) > 0 then found=1;
else if prxmatch("m/If_True|kary/i",name) > 0 then found=2;
else if prxmatch("m/If_False|Jane/i",name) > 0 then found=3;
else if prxmatch("m/If_False|paul/i",name) > 0 then found=4;
else if prxmatch("m/If_Not|Carol/i",name) > 0 then found=5;
else found=0;
run;
quit;
198 data datain;
199 format name $500.;
200 input name &;
201 cards;
202 John__If_True_kary
203 John_If_True__Mary
204 John__If_True1_kary
205 John_If_True_kary
206 Tom__If_Not__Carol
WARNING: The quoted string currently being processed has become more than 262 characters long. You
might have unbalanced quotation marks.
207 Tom__If_Not_Carol
208 Tom_If_Not1_Carol
209 Joe__If_True___Jane
210 Joe__If_False_Jane
211 Joe__If_False__Paul1
212 Joe__If_False___Jane
213 Paul_If_False2__Jane
214 Joe__If_False2___Jane
215 Joe___If_False__Jane
216 ;
217 run;
218 data datain;
219 format name $ 500.;
220 input name &;
221 cards;
222 John__If_True_kary
223 John_If_True__Mary
224 John__If_True1_kary
225 John_If_True_kary
226 Tom__If_Not__Carol
227 Tom__If_Not_Carol
228 Tom_If_Not1_Carol
229 Joe__If_True___Jane
230 Joe__If_False_Jane
231 Joe__If_False__Paul1
232 Joe__If_False___Jane
233 Paul_If_False2__Jane
234 Joe__If_False2___Jane
235 Joe___If_False__Jane
236 ;
237 run;
194 else if prxmatch("m/If_Not|Carol/i",name) > 0 then found=5;
-------------------------
49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.
Inserting white space between a quoted string and the succeeding identifier is
recommended.
194 else if prxmatch("m/If_Not|Carol/i",name) > 0 then found=5;
-------------------------
388
ERROR 388-185: Expecting an arithmetic operator.
194 else if prxmatch("m/If_Not|Carol/i",name) > 0 then found=5;
-------------------------
200
ERROR 200-322: The symbol is not recognized and will be ignored.
238 data dataout;
239 set datain;
240 if
240! prxmatch("m/If_True|mary/i"
-
49
388
200
240! ,name) > 0 then found=1;
241 else if
241! prxmatch("m/If_True|kary/i"
-
49
388
200
241! ,name) > 0 then found=2;
242 else if
242! prxmatch("m/If_False|Jane/i"
-
49
388
200
242! ,name) > 0 then found=3;
243 else if
243! prxmatch("m/If_False|paul/i"
-
49
388
200
243! ,name) > 0 then found=4;
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.
Inserting white space between a quoted string and the succeeding identifier is
recommended.
ERROR 388-185: Expecting an arithmetic operator.
ERROR 200-322: The symbol is not recognized and will be ignored.
244 else if prxmatch("m/If_Not|Carol/i",name) > 0 then found=5;
245 else found=0;
246 run;
247 quit;
My guess is that your error is due to a mistake you made earlier during the session. Restart SAS, run the code again, and see if you still have the error.
Art, CEO, AnalystFinder.com
Post logs with error messages into a code box. The forum icon {i} will open a box that will treat the text pasted a simple text and is not reformatted by the forumn as the example you pasted in the main message window.
This is somewhat important as all of the underscore characters indicate where SAS encountered the error condtion.
So when we see
194 else if prxmatch("m/If_Not|Carol/i",name) > 0 then found=5;
-------------------------
388
ERROR 388-185: Expecting an arithmetic operator.
we do not know if the issue is with a "if prxmatch" paranthese, the > 0 or something else.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.