BookmarkSubscribeRSS Feed
Anandkvn
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 @Anandkvn 

 

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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