BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
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

 

2 REPLIES 2
ed_sas_member
Meteorite | Level 14

Hi @BrahmanandaRao 

 

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;

 

Tom
Super User Tom
Super User

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 3580 views
  • 1 like
  • 3 in conversation