BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NewToAllThis
Obsidian | Level 7

Hi,

 

The below table generates 'Date_Of_Birth' as a date output of DDMMYY and I need YYYMMDD, can anyone help please?

 

Thanks

 

proc sql;
create table table_b as select

Account_Number as Number,
FIRST_NAME_TEXT,
SURNAME_TEXT,
Date_Of_Birth

from table_a;
quit;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@NewToAllThis wrote:
This is working to rearrange the numbers but I needed separators sorry, so I need it to be YYYY/MM/DD 🙂

Spelling counts. The YYMMDDS10. format will add slash   The YYMMDDx has several characters that replace the X to change delimiters.

View solution in original post

5 REPLIES 5
ballardw
Super User

If your source table is actually a SAS data set and the value is a SAS date value, i.e. numeric with the SAS format ddmmyy8 or similar applied all you need is to change the existing format.

proc sql;
create table table_b as select

Account_Number as Number,
FIRST_NAME_TEXT,
SURNAME_TEXT,
Date_Of_Birth format=yymmddn8.

from table_a;
quit;

If you actually want a 3-digit year value though you will have to roll your own and likely have all sorts of fun.

 

If your table is not SAS or your value is character or plain numeric, ie. 301112 with a format like Best or f6. then we need more details as you need to create the SAS date value.

NewToAllThis
Obsidian | Level 7

The date format it is stored in is DATE9. and I need it to read yyyy/mm/dd.  Sorry I missed out a Y earlier 😞

PaigeMiller
Diamond | Level 26
proc sql;
    create table table_b as select
    Account_Number as Number,
    FIRST_NAME_TEXT,
    SURNAME_TEXT,
    Date_Of_Birth format=yymmdd8.
    from table_a;
quit;
--
Paige Miller
NewToAllThis
Obsidian | Level 7
This is working to rearrange the numbers but I needed separators sorry, so I need it to be YYYY/MM/DD 🙂
ballardw
Super User

@NewToAllThis wrote:
This is working to rearrange the numbers but I needed separators sorry, so I need it to be YYYY/MM/DD 🙂

Spelling counts. The YYMMDDS10. format will add slash   The YYMMDDx has several characters that replace the X to change delimiters.

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!

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
  • 5 replies
  • 846 views
  • 3 likes
  • 3 in conversation