|
Ash,
This has been discussed on SAS-L a number of times already and, quite
frankly, there isn't an all-inclusive solution that I'm aware of.
The following code is just an expansion of Oleg's proposed solution, but
it most definitely has its limitations and won't correctly identify all
date variables. However, that said, it might give you some insights into
how you might solve your problem:
* build test data set;
data test;
informat var1 $9.;
input something date9. var1 $ var2;
attrib
birthday length = 8
birthday format = mmddyy10.
date1 length = 8
another informat = date9.
;
birthday = today();
date1 = today();
another= today();
testvar1=input(var1,anydtdte.);
if missing(testvar1) then
testvar1=input(var1,date9.);
if not(missing(testvar1)) then do;
format testvar1 date9.;
end;
testvar2=input(put(var2,date9.),date9.);
if not(missing(testvar2)) then do;
format testvar2 date9.;
end;
cards;
12DEC2008 04151944 17921
12DEC2007 0415194 17922
12DEC2007 15041944 17923
12DEC2007 15APR1944 3
;
* put column names into macro variable mv ;
proc sql noprint;
select name into :mv separated by ' '
from dictionary.columns
where libname = "WORK"
and memname = "TEST"
and (index(lowcase(name),"date")>0 or
index(lowcase(name),"dt")>0 or
index(format,"DATE")>0 or
index(informat,"DATE")>0 or
index(format,"YY")>0 or
index(informat,"YY")>0 or
index(format,"DT")>0 or
index(informat,"DT")>0 or
index(format,"JULIAN")>0 or
index(informat,"JULIAN")>0
)
;
quit;
%put &mv;
Art
--------
On Thu, 22 Jan 2009 06:59:41 -0800, ash007 <RamsamyAshley@GMAIL.COM> wrote:
>I want to put all the date variable in a macro variable. thanks.
>
>mv = date1 date2 ....
|