proc sql;
create table Orders (OrderID num(8), CustomerID num(5) , OrderDate format =yyyymmdd10.);
insert into Orders values (10308, 2, 1996-09-18);
insert into Orders values (10309, 37, 1996-09-18);
insert into Orders values (10310, 77 ,1996-09-18);
quit;
30 proc sql;
31 create table Orders (OrderID num(8), CustomerID num(5) , OrderDate format
------
22
76
31 ! =yyyymmdd10.);
ERROR 22-322: Syntax error, expecting one of the following: CHAR, CHARACTER, DATE, DEC,
DECIMAL, DOUBLE, FLOAT, INT, INTEGER, NUM, NUMERIC, REAL, SMALLINT,
VARCHAR.
ERROR 76-322: Syntax error, statement will be ignored.
32 insert into Orders values (10308, 2, 1996-09-18);
ERROR: File WORK.ORDERS.DATA does not exist.
33 insert into Orders values (10309, 37, 1996-09-18);
ERROR: File WORK.ORDERS.DATA does not exist.
34 insert into Orders values (10310, 77 ,1996-09-18);
ERROR: File WORK.ORDERS.DATA does not exist.
35 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.25 seconds
cpu time 0.01 seconds
You can try this:
- specify the data type for OrderDate -> num
- correct the format : yymmdd10. instead of yyyymmdd10.
- you can have just one statement to specify values. To use the 'values' clauses, please specify the column names in the correct order and in parenthesis just after the table name.
- indicates to SAS that the values for OrderDate are SAS dates -> 'ddmonyyyy'd
proc sql;
create table Orders (OrderID num(8), CustomerID num(5) , OrderDate num format=yymmdd10.);
insert into Orders (OrderID, CustomerID, OrderDate)
values (10308, 2, '18SEP1996'd)
values (10309, 37, '18SEP1996'd)
values (10310, 77 ,'18SEP1996'd);
quit;
Note that the expression (1996-09-18) evaluates to the number 1,969 which is the 23rd day of May 1965.
100 data test; 101 x=1996-09-18; 102 put x=comma10. ' As Date=' x date9. ; 103 run; x=1,969 As Date=23MAY1965 NOTE: The data set WORK.TEST has 1 observations and 1 variables.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.