- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 06-21-2010 03:57 PM
(3100 views)
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?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
try using this
if disc_date in ( '13oct2003'd ) then disc_date = .;
GL
if disc_date in ( '13oct2003'd ) then disc_date = .;
GL
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Ie
(MDY(10,13,2003) MDY(11,11,2003) MDY(11,27,2003)) might work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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