BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10
proc sql;
create table countries (name char(25), Capital char(25), Population num(45), Area num(35), 
Contant char(25), UNDate num informat=year4. format=year4. );
insert into countries values('Afghanistan','Kabul',17070323,251825,'Asia',1946);
quit;

In the above insert UNDate value 1946 problem output it gives 1965

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

On top of what @Kurt_Bremser said:

Informats on a table don't come into play when using a SQL insert statement. You need already to provide in the insert statement the value that matches the data type.

Informats come into play when using an INPUT statement.

 

Code below that uses a valid informat to demonstrate what I just wrote.

proc sql;
  create table countries (
    name char(25), 
    Capital char(25), 
    Population num(45), 
    Area num(35), 
    Contant char(25),
    UNDate num informat=date9. 
    );
  insert into countries values('Afghanistan','Kabul',17070323,251825,'Asia','10Mar2023');
quit;

Patrick_0-1682933061626.png

 

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User
  1. There is no YEAR informat
  2. Maxim 1: Read the Documentation: YEAR Format Study the documentation closely, and you will see why this conversion happens. Hint: see what kind of data the format expects; in which year is the 1946th day after 1960-01-01?
Patrick
Opal | Level 21

On top of what @Kurt_Bremser said:

Informats on a table don't come into play when using a SQL insert statement. You need already to provide in the insert statement the value that matches the data type.

Informats come into play when using an INPUT statement.

 

Code below that uses a valid informat to demonstrate what I just wrote.

proc sql;
  create table countries (
    name char(25), 
    Capital char(25), 
    Population num(45), 
    Area num(35), 
    Contant char(25),
    UNDate num informat=date9. 
    );
  insert into countries values('Afghanistan','Kabul',17070323,251825,'Asia','10Mar2023');
quit;

Patrick_0-1682933061626.png

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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