Today we are going to discuss about, how to read dates in SAS, which are in multiple format in raw data.
Suppose we have dates in raw data which contains multiple types of separators and formats.
We would read such type of mixed date data and make all dates in one required format. We have two master blaster functions to perform this task :INDEXC and WORDDATE
SAS Code would be as follows:
Data DSN;
Input @1 Dummy_Dates $15.;
If INDEXC (Dummy_Dates,'-/:') NE 0
Then Date=Input(Dummy_Dates,MMDDYY10.);
Else Date=Input(Dummy_Dates,Date9.);
Format Date WORDDATE.;
Drop Dummy_Dates;
Cards;
10/07/2014
10MAY1984
8-12-1999
1:09:60
;
Run;
For more on INDEXC : What Is The Difference Between SAS Character Functions INDEX And INDEXC
Suppose we have dates in raw data which contains multiple types of separators and formats.
We would read such type of mixed date data and make all dates in one required format. We have two master blaster functions to perform this task :INDEXC and WORDDATE
SAS Code would be as follows:
Data DSN;
Input @1 Dummy_Dates $15.;
If INDEXC (Dummy_Dates,'-/:') NE 0
Then Date=Input(Dummy_Dates,MMDDYY10.);
Else Date=Input(Dummy_Dates,Date9.);
Format Date WORDDATE.;
Drop Dummy_Dates;
Cards;
10/07/2014
10MAY1984
8-12-1999
1:09:60
;
Run;
For more on INDEXC : What Is The Difference Between SAS Character Functions INDEX And INDEXC
No comments:
Post a Comment