BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
proc sql;
create table order (oder_ID num(1),ProductName varchar2(25),	OrderDate num format=yymmdd10.;
insert into order values(1,'Geitost','2008-11-11'd);
insert into order values(2,'Camembert Pierrot','2008-11-09'd);
insert into order values(3,'Mozzarella	di Goviovanni','2008-11-11'd);
insert into order values(4,'Mascarpone Fabioli','2008-10-29'D);
quit;

date format 

4 REPLIES 4
ed_sas_member
Meteorite | Level 14

Hi @BrahmanandaRao 

 

In the CREATE TABLE statement, there is a missing parenthesis and a mispelling.

In the INSERT INTO statement, you must use a 'date' format to specify date values (such as date9.: DDMONYYYY)

 

proc sql;
create table order (oder_ID num(1),ProductName varchar(25), OrderDate num format=yymmdd10.);
insert into order values(1,'Geitost','11NOV2008'd);
insert into order values(2,'Camembert Pierrot','09NOV2008'd);
insert into order values(3,'Mozzarella di Goviovanni','11NOV2008'd);
insert into order values(4,'Mascarpone Fabioli','29OCT2008'd);
quit;
 
Best,
 
 
BrahmanandaRao
Lapis Lazuli | Level 10

orderdate num format=date9. 

not working

ed_sas_member
Meteorite | Level 14

That's not what I said -> you need to specify values as '11NOV2008'd and not '2008-11-11'd

The below query is the correction:

 

proc sql;
create table order (oder_ID num(1),ProductName varchar(25), OrderDate num format=yymmdd10.);
insert into order values(1,'Geitost','11NOV2008'd);
insert into order values(2,'Camembert Pierrot','09NOV2008'd);
insert into order values(3,'Mozzarella di Goviovanni','11NOV2008'd);
insert into order values(4,'Mascarpone Fabioli','29OCT2008'd);
quit;
Kurt_Bremser
Super User

You should start to actually read our answers to your "questions". You have been shown how to supply date literals (in SQL, on top) at least once, like here: https://communities.sas.com/t5/SAS-Programming/proc-sql-column-date-datatype/td-p/594431 

 

And why are you abusing SQL for a simple creation of a dataset, that's much easier done in a data step with datalines.

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!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 598 views
  • 0 likes
  • 3 in conversation