Desktop productivity for business analysts and programmers

Number Format to Date Format

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Number Format to Date Format

Good afternoon all,

 

I've been trying for the past couple of days to join two tables, however, I cannot join them because of different data types.

 

In one table, I have a column 'PERIOD_START_DT' (coming from a datasource that cannot be changed) with a $10. number format which reads '2015-10-25'. The other table has a column 'YrWk' with a date format MMDDYY10. which reads '04/02/2017'.

 

I need to convert PERIOD_START_DT to MMDDYY10, but I havent had any luck. First I tried chaning the format in the PROC SQL statment, then I moved to try to use a DATA step before a PROC SQL step to format it. Both were equally unsuccessful.

 

Any recommendations on how to approach this?

 

Thanks!


Accepted Solutions
Solution
‎04-27-2017 04:05 PM
Esteemed Advisor
Posts: 7,293

Re: Number Format to Date Format

data want (drop=_:);
  set have (rename=(PERIOD_START_DT=_PERIOD_START_DT));
  format PERIOD_START_DT MMDDYY10.;
  PERIOD_START_DT=input(_PERIOD_START_DT,yymmdd10.);
run;

Art, CEO, AnalystFinder.com

View solution in original post


All Replies
Solution
‎04-27-2017 04:05 PM
Esteemed Advisor
Posts: 7,293

Re: Number Format to Date Format

data want (drop=_:);
  set have (rename=(PERIOD_START_DT=_PERIOD_START_DT));
  format PERIOD_START_DT MMDDYY10.;
  PERIOD_START_DT=input(_PERIOD_START_DT,yymmdd10.);
run;

Art, CEO, AnalystFinder.com

New Contributor
Posts: 2

Re: Number Format to Date Format

.... THANK YOU SO MUCH. 

 

I thought I had tried that exact same thing but clearly I didnt becasue this worked perfectly!

 

Thanks again,

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 139 views
  • 1 like
  • 2 in conversation