I am facing a difficulty whereby I couldn't find a way to read the source character values to determine if it is a date format (possible in YYYYMMDD and MMDDYYYY) or other character format such as car_0001.
Sample as below.
data test;
value1='19990131';
value2='12312006';
value3='car_0001';
value4='blue_001';
run;
As we can see from above, each columns have its own value.
Is there a way that I can identify value 1 as YYYYMMDD, value 2 as MMDDYYYY, or value 3 and 4 as character (nondate)?
I couldn't think of a function to do so.
data test;
value='19990131'; output;
value='12312006'; output;
value='car_0001'; output;
value='blue_001'; output;
run;
data want;
set test;
date=input(value,anydtdte.);
run;
If the value of DATE is missing, then it is not recognized as a SAS date. This method, using informat ANYDTDTE, is not perfect, it won't give you the proper answer 100% of the time.
data test;
value='19990131'; output;
value='12312006'; output;
value='car_0001'; output;
value='blue_001'; output;
run;
data want;
set test;
date=input(value,anydtdte.);
run;
If the value of DATE is missing, then it is not recognized as a SAS date. This method, using informat ANYDTDTE, is not perfect, it won't give you the proper answer 100% of the time.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: