Hi,
I have a folder with a 30-40 datasets. I have created a macro to look for dates within those datasets but keep getting errors for datasets that don't have dates in them.
How can I create a macro for fields that only have "Date" in the variable name and will check all datasets within a folder?
For example,
data path.dates; FirstName $ LastName $ StartDate EndDate ; datalines; Bill Smith 201902 20190301 Ben Junior 2019 20190131 ; run;
data path.nondates; FirstName $ LastName$ City $; datalines; Linda Davis NY Sue Smith LA ; run;
want to add dashes to all fields within the folder that have "Date" in the variable name:
proc sql;
create table path.? as select *, case when length(strip(Date?)) = 8 then catx("-", substr(strip(Date?), 1,4) ,substr(strip(Date?),5,2), substr(strip(Date?),7, 2)) when length(strip(Date?)) = 6 then catx("-", substr(Date?, 1,4),substr(Date?,5,2)) else Date? end as Date? from path.? ; Quit;
Thanks for your help
... View more