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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 778 views
  • 0 likes
  • 3 in conversation