DATA Step, Macro, Functions and more

Function to Split SaS Data-Set Column

Reply
Occasional Contributor
Posts: 5

Function to Split SaS Data-Set Column

Dear All,

 

I have Column(OrderDate) Consists of Value in date Format ( 05/10/2017) .

And I wold like to split the data value in three different columns to OrderDay ,OrderMonth,OrderYear 

Can any one help me how can I do this.

Super User
Posts: 6,936

Re: Function to Split SaS Data-Set Column

If OrderDate is a SAS date variable (days from 01/01/1960), then the functions year(), month() and day() will do the trick.

If it is not, convert it first.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Trusted Advisor
Posts: 1,377

Re: Function to Split SaS Data-Set Column

to continue @KurtBremser answer -

 

If the OrederDate is charachter type use function scan:

   day = scan(OrederDate,1,'/');

  mon = scan(OrederDate,2,'/');

  year = scan(OrederDate,3,'/');

 

Ask a Question
Discussion stats
  • 2 replies
  • 96 views
  • 0 likes
  • 3 in conversation