Help using Base SAS procedures

WHERE in SAS

Reply
N/A
Posts: 0

WHERE in SAS

Hi All,

I use:-


data exam;
input name $ class $ score ;
cards;
Tim math 9
Tim history 8
Tim science 7
Sally math 10
Sally science 7;
run;


data student1;
set exam;
where name = ‘Tim’ or name = ‘Sally’;
run;

I get error:

ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, (, *, +, -, :, INPUT, NOT,
PUT, ^, ~.


Kindly guide.
K.
SAS Super FREQ
Posts: 8,740

Re: WHERE in SAS

Hi:
I can duplicate your error message if I cut and paste code from Microsoft Word that uses "slanted" quotes instead of "regular" quotes. For example:
[pre]
142 where name = ‘Tim’ or name = ‘Sally’;
-
22
76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, (, *, +, -, :,
INPUT, NOT, PUT, ^, ~.

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

143 run;
[/pre]

Notice the "slanted" quote marks. If, on the other hand, I type in Notepad or in SAS Display Manager or use the "unslanted" quotes, the WHERE statement does not generate an error message:
[pre]
158 where name = 'Tim' or name = 'Sally';
159 run;

NOTE: There were 5 observations read from the data set WORK.EXAM.
WHERE name in ('Sally', 'Tim');
NOTE: The data set WORK.STUDENT1 has 5 observations and 3 variables.
[/pre]

Perhaps if you try retyping your WHERE clause and ensure that there are no "slanted" quotes, you will have success.

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 274 views
  • 0 likes
  • 2 in conversation