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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 781 views
  • 0 likes
  • 3 in conversation