How to convert a SAS numeric date value to SAS date format in PROC SQL

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

How to convert a SAS numeric date value to SAS date format in PROC SQL

How do I save a SAS numeric date value into SAS date format in PROC SQL. Currently, I have  a DATA step to convert the variable to SAS date format using FORMAT mydate MMDDYY10.   Can I directly convert the SAS numeric value to date format(mm/dd/yyyy)  in PROC SQL ? Appreciate any assistance. Thank you


Accepted Solutions
Solution
‎03-12-2018 12:18 PM
Super User
Super User
Posts: 9,599

Re: How to convert a SAS numeric date value to SAS date format in PROC SQL

Yep.

    intnx('month',serv_from_date, 0,'e') as EOM_DOS format=mmddyy10.

View solution in original post


All Replies
Super User
Super User
Posts: 9,599

Re: How to convert a SAS numeric date value to SAS date format in PROC SQL

Sure, you can use SAS functions and formats in SQL so long as your not using pass-through, e.g:

proc sql;
  create table want as
  select date_num format=mmddyy10.
  from  have;
quit;
Occasional Contributor
Posts: 19

Re: How to convert a SAS numeric date value to SAS date format in PROC SQL

I am creating a new variable for the end of the month of my service date  , can I use the FORMAT function below? Sorry, I am a SAS newbie.

proc sql;

 create table want as
   select

    serv_from_date,

    intnx('month',serv_from_date, 0,'e') as EOM_DOS

   
  from  have;
quit;

 

PROC Star
Posts: 509

Re: How to convert a SAS numeric date value to SAS date format in PROC SQL

 

Just use @RW9 code within new variable as

proc sql;

 create table want as
   select

    serv_from_date,

    intnx('month',serv_from_date, 0,'e') as EOM_DOS format =mmddyy10.

   
  from  have;
quit;

 
Solution
‎03-12-2018 12:18 PM
Super User
Super User
Posts: 9,599

Re: How to convert a SAS numeric date value to SAS date format in PROC SQL

Yep.

    intnx('month',serv_from_date, 0,'e') as EOM_DOS format=mmddyy10.

Occasional Contributor
Posts: 19

Re: How to convert a SAS numeric date value to SAS date format in PROC SQL

Perfect. Thank you all!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 176 views
  • 0 likes
  • 3 in conversation