Help using Base SAS procedures

sql

Reply
N/A
Posts: 0

sql

Hi,

I am getting an error on this below code:

data svc(keep=aaa ddd);
set &libn1..svcs;
if cod=('21'and '31');
run;

Error:
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended.

Thanks in advance.
Raj
SAS Super FREQ
Posts: 8,868

Re: sql

Posted in reply to deleted_user
Hi:
I believe you are getting that message because you do not have a space:
[pre]
if cod=('21'and '31');
--
[/pre]
between the ' and the 'a' for and

However, it is probably a moot point, since the syntax of your IF statement is incorrect. For some examples of how to code an IF statement, refer to the documentation examples found here:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000201978.htm
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000202239.htm
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm

For one thing, it would be impossible for 1 variable to hold 2 values on a single observation so you would never find an observation where the value for COD was both '21' AND '31'. So I suspect you want to subset those observations where the value for code is either '21' or is '31'.

You could use either of these forms of subsetting IF:
[pre]
if cod='21' or cod='31';
OR
if cod in ('21', '31');
[/pre]

cynthia
N/A
Posts: 0

Re: sql

Posted in reply to Cynthia_sas
Thanks Cynthia !!!

It works out !!
Ask a Question
Discussion stats
  • 2 replies
  • 107 views
  • 0 likes
  • 2 in conversation