BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
proc sql;
create table cust_orders(ord_no num(8),purch_amt num(10,2),ord_date num format=yymmdd10.,customer_id num(6),salesman_id num(6));

insert into cust_orders values (70001   ,   150.5     ,  '2012oct05'd , 3005  , 5002);
insert into cust_orders values (70009   ,   270.65    ,  '2012sep10'd , 3001  , 5005);
insert into cust_orders values (70002   ,   65.26     ,  '2012oct05'd , 3002  , 5001);
insert into cust_orders values (70004   ,   110.5     ,  '2012aug17'd , 3009  , 5003);

quit;
3 REPLIES 3
ed_sas_member
Meteorite | Level 14

Hi @BrahmanandaRao 

 

The date should be entered like this: 'DDmonYYYY'd

e.g. 

 

'05oct2012'd

 

 

You can also simplify you code as follows (by using 1 INSERT INTO statement)

proc sql;
	create table cust_orders(ord_no num,purch_amt num, ord_date num format=yymmdd10.,customer_id num,salesman_id num);

	insert into cust_orders
		values (70001   ,   150.5     ,  '05oct2012'd , 3005  , 5002)
		values (70009   ,   270.65    ,  '10sep2012'd , 3001  , 5005)
		values (70002   ,   65.26     ,  '05oct2012'd , 3002  , 5001)
		values (70004   ,   110.5     ,  '17aug2012'd , 3009  , 5003);

quit;

NB: PROC SQL enables you to specify a column width for character columns but not for numeric columns.

 

ballardw
Super User

SAS date literals must be in the appearance of something displayed using the SAS DATE. format.

Examples:

Date7.:  'ddMONyy'd

Date9.:  'ddMONyyyy'd

Date11.: 'dd-MON-yyyy'd

Tom
Super User Tom
Super User

@ballardw wrote:

SAS date literals must be in the appearance of something displayed using the SAS DATE. format.

Examples:

Date7.:  'ddMONyy'd

Date9.:  'ddMONyyyy'd

Date11.: 'dd-MON-yyyy'd


Or more accurately something that the DATE **informat** can read.

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