BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hello,

 

An error massage is shown in my coding.   Please correct, thanks.

 

198 DATA Text;

199 set Text;

200 IF result ^= '' and Source__Type in ('Nasopharyngeal swab' or 'Throat

                                                                                                      ---

79

388

200

76

200! (Oropharyngeal) swab' or 'Oral swab');

ERROR 79-322: Expecting a ).

ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

201 run;

 


DATA want;
	set text;
	if Result_t ^= '' and Source__Type_ in ('Nasopharyngeal swab' or 'Throat (Oropharyngeal) swab');
run;

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Try this

 

DATA want;
	set text;
	if Result_t ^= '' and Source__Type_ in ('Nasopharyngeal swab', 'Throat (Oropharyngeal) swab');
run;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Try this

 

DATA want;
	set text;
	if Result_t ^= '' and Source__Type_ in ('Nasopharyngeal swab', 'Throat (Oropharyngeal) swab');
run;
ybz12003
Rhodochrosite | Level 12

Can't believe that forgot the comma!Woman Embarassed

Tom
Super User Tom
Super User

@ybz12003 wrote:

Can't believe that forgot the comma!Woman Embarassed


SAS does NOT need a comma between the items listed when using the IN operator.

proc print data=sashelp.class;
  where age in (11 12)
    or name in ('Alfred' 'Alice')
  ;
run;

Your problem is that you gave the IN operator a variable name when it wanted a list of character values.

2991  proc print data=sashelp.class;
2992    where age in (11 12)
2993      or name in ('Alfred' or 'Alice')
                               --
                               22
                               202
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ), ','.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
2994    ;
ERROR: Syntax error while parsing WHERE clause.
2995  run;

3001  proc print data=sashelp.class;
3002    where age in (11 12)
3003      or name in ('Alfred' 123 'Alice')
                               ---
                               22
                               200
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ), ','.
ERROR 200-322: The symbol is not recognized and will be ignored.
3004    ;
ERROR: Syntax error while parsing WHERE clause.
3005  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


3006  proc print data=sashelp.class;
3007    where age in (11 12)
3008      or name in ('Alfred' age 'Alice')
                               ---
                               22
                               202
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ), ','.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
3009    ;
ERROR: Syntax error while parsing WHERE clause.
3010  run;

 

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 910 views
  • 0 likes
  • 3 in conversation