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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1568 views
  • 0 likes
  • 5 in conversation