DATA Step, Macro, Functions and more

proc sql for date

Accepted Solution Solved
Reply
Contributor scb
Contributor
Posts: 50
Accepted Solution

proc sql for date

I have attached a sample dataset.

 

I can get the date format in date9. in data step.

 

DATA SAMPLE1;
FORMAT SAMPLE_DT1 DATE9.;
SET SAMPLE;
SAMPLE_DT1 = DATEPART(SAMPLE_DT);
RUN;

 

May i know how to get similar answer in PROC SQL? I used datepart in SQL but could not get it.  Any idea? Thanks.

Attachment

Accepted Solutions
Solution
‎12-20-2016 03:43 AM
Frequent Contributor
Posts: 96

Re: proc sql for date

[ Edited ]

Try this one:

PROC SQL;
SELECT * , DATEPART(SAMPLE_DT) AS  SAMPLE_DT1 FORMAT=date9.
FROM sample;
quit;

View solution in original post


All Replies
Solution
‎12-20-2016 03:43 AM
Frequent Contributor
Posts: 96

Re: proc sql for date

[ Edited ]

Try this one:

PROC SQL;
SELECT * , DATEPART(SAMPLE_DT) AS  SAMPLE_DT1 FORMAT=date9.
FROM sample;
quit;
☑ This topic is SOLVED.

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

Discussion stats
  • 1 reply
  • 121 views
  • 0 likes
  • 2 in conversation