BookmarkSubscribeRSS Feed
jetia13
Calcite | Level 5
This seems like a simple problem, but it's making me crazy.

So I'm trying to say that if a date variable (disc_date) is equal to one of a certain set of dates, it should be set to missing.

Here is the code i'm using:

if disc_date in (MDY(10,13,2003),MDY(11,11,2003),MDY(11,27,2003),MDY(11,28,2003),MDY(1,19,2004),MDY(2,12,2004),MDY(2,16,2004),MDY(3,1,2004),MDY(5,31,2004)) then disc_date = .D;

I get the error:
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, iterator, (.

indicating the first "MDY" function.
Why doesn't it like this??

Anyone have any ideas?
5 REPLIES 5
deleted_user
Not applicable
try using this

if disc_date in ( '13oct2003'd ) then disc_date = .;

GL
Reeza
Super User
I thought the in (a b c d) didn't use comma's.

Ie

(MDY(10,13,2003) MDY(11,11,2003) MDY(11,27,2003)) might work.
Cynthia_sas
SAS Super FREQ
Hi:
I always use a comma. Although I believe in some circumstances, the IN operator will be forgiving.

When in doubt, it's always a good idea to check the documentation.
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/e...

cynthia
Pavan_SAS
SAS Employee
hi all,

that error is not because of comma or space delimiter.
its becas of using sas function inside the IN operator.
We should have to use numeric or character constants as arguments for IN operator (not sas functions....)

It doesn't matter whether u r using comma or space as delimiter. both r acceptable.

Pavan. Message was edited by: Pavan@SAS
Cynthia_sas
SAS Super FREQ
You are correct that the original error was the use of the MDY function with the IN operator, when the date constant or a SAS date value would have been the preferred approach.

However, my comment was ONLY addressing the use of commas or not. IN will allow spaces, but the documentation shows the use of commas.

cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 2023 views
  • 0 likes
  • 5 in conversation