DATA Step, Macro, Functions and more

Importing dates into SAS

Accepted Solution Solved
Reply
Contributor
Posts: 52
Accepted Solution

Importing dates into SAS

Quick question that I have spent a lot of time trying to figure out with no luck.

 

I have dates in the form 201601, 201602, etc. that I want to convert from numeric to a SAS date while keeping this format (yyyymm). How do you convert this in SAS?  

 

Thanks

Jack


Accepted Solutions
Solution
‎02-01-2017 03:29 PM
Trusted Advisor
Posts: 1,401

Re: Importing dates into SAS

the easyest way:

  date = input(put(date_in,z6.)||'01' , yymmdd8.);

  format date yymmddn6.;

View solution in original post


All Replies
Solution
‎02-01-2017 03:29 PM
Trusted Advisor
Posts: 1,401

Re: Importing dates into SAS

the easyest way:

  date = input(put(date_in,z6.)||'01' , yymmdd8.);

  format date yymmddn6.;

Contributor
Posts: 52

Re: Importing dates into SAS

Works! Thanks.  Jack

Super User
Posts: 10,538

Re: Importing dates into SAS

Are you reading an external file or are converting data already in SAS?

If reading an external file with a data step you can use the informat yymmn6. and display format yymmn6. ;

 

Note that this and @Shmuel's suggestion will both have an implicit value including the first day of the month.

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 107 views
  • 0 likes
  • 3 in conversation