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.

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