I am trying to write a SAS script that will simply read in a SAS .sas7bdat data file and output it in text format. I want dates to be output in YYYYMMDD format. I don't know what the names of the date columns will be. My script is currently:
libname tmplib '~/testdatadir/';
OPTIONS MISSING='00'x;
data tmpdata;
set tmplib.testdatafile;
array flds{*} _NUMERIC_;
do i=1 to dim(flds);
if missing(flds(i)) then flds(i)=.;
end;
array charflds{*} _CHARACTER_;
do i=1 to dim(charflds);
if missing(charflds(i)) then charflds(i)=' ';
end;
drop i;
RUN;
PROC EXPORT
DATA = tmpdata
OUTFILE = 'testdataoutfile.txt'
DBMS = TAB REPLACE;
PUTNAME = YES;
RUN;
I would either like to iterate through all date fields (as I do with NUMERIC fields and CHARACTER fields), or add a check for each NUMERIC field testing whether it is a date (then I could change the format), or add an option to PROC EXPORT to indicate the output date format. Any other approach to get the output file to have dates formatted as YYYYMMDD would be acceptable as well.