good day
am running the below code , however it returns the error listed above
PROC SQL;
CREATE TABLE VIEW AS
SELECT *
FROM have
WHERE DATE_OPENED => 2023-04-10 ;
QUIT;
The data is specified incorrectly. That format is ambiguous as it could be a subtraction or date.
Date constants in SAS are specified using 'DDMMMYY'd format, assuming this is a SAS date that's numeric. If date_opened is a character variable, you need to include it in quotes and due to numeric order it will still return the correct value.
DATE_OPENED is numeric (SAS date format)
PROC SQL;
CREATE TABLE VIEW AS
SELECT *
FROM have
WHERE DATE_OPENED => '10Apr2023'd ;
QUIT;
DATE_OPENED is character
PROC SQL;
CREATE TABLE VIEW AS
SELECT *
FROM have
WHERE DATE_OPENED => '2023-04-10' ;
QUIT;
@VALLY wrote:
good day
am running the below code , however it returns the error listed above
PROC SQL; CREATE TABLE VIEW AS SELECT * FROM have WHERE DATE_OPENED => 2023-04-10 ; QUIT;
You need to share the LOG to clarify what error you are getting.
476 PROC SQL; 477 CREATE TABLE VIEW AS 478 SELECT * 479 FROM have 480 WHERE DATE_OPENED => 2023-04-10 ; - 22 ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER. 481 QUIT;
Looks like SQL does not like the use of = followed by >. Did you mean "greater than or equal to"? If so then you need to use >= or better still use the GE pneumonic instead.
The code has other issues also.
498 data _null_; 499 x=2023-04-10 ; 500 put x= comma. x=date9. x=datetime19.; 501 run; x=2,009 x=02JUL1965 x=01JAN1960:00:33:29
In addition to the => error mentioned above, you also have this error:
2023-04-10
is how you do subtraction in SAS. SAS thinks you mean 2023 minus 4 minus 10. It is not a date (normally). Maybe you mean
'04OCT2023'd
which SAS will always recognize as the date October 4, 2023; or maybe you mean something else.
The data is specified incorrectly. That format is ambiguous as it could be a subtraction or date.
Date constants in SAS are specified using 'DDMMMYY'd format, assuming this is a SAS date that's numeric. If date_opened is a character variable, you need to include it in quotes and due to numeric order it will still return the correct value.
DATE_OPENED is numeric (SAS date format)
PROC SQL;
CREATE TABLE VIEW AS
SELECT *
FROM have
WHERE DATE_OPENED => '10Apr2023'd ;
QUIT;
DATE_OPENED is character
PROC SQL;
CREATE TABLE VIEW AS
SELECT *
FROM have
WHERE DATE_OPENED => '2023-04-10' ;
QUIT;
@VALLY wrote:
good day
am running the below code , however it returns the error listed above
PROC SQL; CREATE TABLE VIEW AS SELECT * FROM have WHERE DATE_OPENED => 2023-04-10 ; QUIT;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.