I guess I'm confused by your description of what you want. At first, I thought you wanted to search through a library and find out whether there were any date variables based on looking up the variable format compared to a list. But then some other folks interpreted your question as wanting to know whether the variable VALUES were valid date or date/time values. However, I'm going to stick with my original interpretation...and guess that this most recent question has to do with the fact that the documentation lists just the "base" name of the format (or informat) and doesn't show a width, while in actual usage, the format width can vary.
For example, as you note, a variable could be defined for actual usage with a format of DDMMYY10 or DDMMYY8 or MMDDYY10 or MMDDYY6 or MMDDYY8. So yes, the WIDTH of the formatted field could always be different in the dataset descriptor. However, the basic format name for the above 2 examples is either DDMMYY or MMDDYY....without regard to the WIDTH of the formatted value. You can easily read the FORMAT variable out of DICTIONARY.COLUMNS and extract only the character portion of the format name using the SCAN function. Something like this:
[pre]
method1 = scan(fmtval,1,'1234567890.');
method2 = scan(fmtval,1,,'dp');
[/pre]
The first scan method statement just hard-codes digits and a period as the delimiters for the SCAN function. The second method uses the 'dp' modifiers to the SCAN function instead of typing the list of numbers and punctuation. In either case, the result of using both methods would be that MMDDYY8. and MMDDYY10. as format values would become MMDDYY ... In the program below, I use the first method to compare formats from DICTIONARY.COLUMNS against a small checklist dataset of format names. Partial output from the program is shown after the program.
With this report in hand, you could either code a macro program or code a series of PROC FREQ, PROC MEANS or PROC UNIVARIATE steps to test the values in these particular variables to see what the range of date or date/time values was and whether they were reasonable values for the processing you need to do.
cynthia
[pre]
data checklist;
infile datalines;
input fwant $;
select_match = 'FORMAT';
fwant = upcase(fwant);
return;
datalines;
date
mmddyy
monname
weekdate
datetime
;
run;
ods listing;
options linesize=150;
proc sql;
create table datevars as
select b.select_match, a.libname, a.memname, a.name, a.type,
a.informat, a.format,
scan(a.format,1,'1234567890.') as f_name,
a.length, a.label
from dictionary.columns as a,
work.checklist as b
where (calculated f_name = b.fwant)
order by a.libname, a.memname, a.name;
quit;
proc print data=work.datevars;
title 'Date variables in DICTIONARY.COLUMNS with date format';
run;
[/pre]
Partial output:
[pre]
select_
Obs match libname memname name type informat format f_name length label
1 FORMAT MAPS NCC DATE num DATETIME20. DATETIME 8
2 FORMAT MAPS NCD DATE num DATETIME20. DATETIME 8
3 FORMAT MAPS NCN DATE num DATETIME20. DATETIME 8
4 FORMAT MAPS USAC DATE num DATETIME20. DATETIME 8
5 FORMAT MAPS USAD DATE num DATETIME20. DATETIME 8
6 FORMAT MAPS USAN DATE num DATETIME20. DATETIME 8
7 FORMAT MAPS WAKEC DATE num DATETIME20. DATETIME 8
8 FORMAT MAPS WAKED DATE num DATETIME20. DATETIME 8
9 FORMAT MAPS WAKEN DATE num DATETIME20. DATETIME 8
10 FORMAT SASHELP ASSOCWA _LOADTM num DATETIME20. DATETIME20. DATETIME 8 DateTime Stamp of when row was loaded
11 FORMAT SASHELP BUY DATE num DATE9. DATE 8 Date
12 FORMAT SASHELP CITIDAY DATE num DATE9. DATE 7 Date of Observation
13 FORMAT SASHELP GNGSMP2 Date num DATE. DATE 8
14 FORMAT SASHELP GNGSMP2 DateTime num DATETIME14. DATETIME 8
15 FORMAT SASHELP MDV SHIPDATE num DATE. DATE7. DATE 8
16 FORMAT SASHELP NVST1 DATE num DATE9. DATE 8 Date
17 FORMAT SASHELP NVST2 DATE num DATE9. DATE 8 Date
18 FORMAT SASHELP NVST3 DATE num DATE9. DATE 8 Date
19 FORMAT SASHELP NVST4 DATE num DATE9. DATE 8 Date
20 FORMAT SASHELP NVST5 DATE num DATE9. DATE 8 Date
21 FORMAT SASHELP PRDSAL2 MONTH num MONNAME3. MONNAME 8 Month
22 FORMAT SASHELP PRDSAL3 MONTH num MONNAME3. MONNAME 8 Month
23 FORMAT SASHELP PRDSALE MONTH num MONNAME3. MONNAME 8 Month
[/pre]