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

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

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yep.

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

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
lmtamina
Obsidian | Level 7

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;

 

kiranv_
Rhodochrosite | Level 12

 

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;

 
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yep.

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

lmtamina
Obsidian | Level 7

Perfect. Thank you all!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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