BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Anandkvn
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 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!

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.

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