I'd like to pull date from a long character field.
For instance:
Out of another, I get a lovely view of the bay on 8/23/20 and a little private wharf belonging to the estate. There is a beautiful shaded lane that runs down there from the house. I always fancy I see people walking on 5/5/20.
From this I'd like my output to be:
date=08/23/2020
date=05/05/2020
Please help. Thanks!
Use regular expressions matching. You can iterate the matches with prxNext:
data want;
if not prxId then prxId + prxParse("@\d\d?/\d\d?/\d\d(\d\d)?@");
set have;
start = 1;
stop = length(text);
call prxnext(prxID, start, stop, text, position, length);
do while (position > 0);
date = input(substr(text, position, length), ?? mmddyy10.);
if not missing(date) then output;
call prxnext(prxID, start, stop, text, position, length);
end;
keep date;
format date yymmdd10.;
run;
Can a sentence be "I'll see you on the first day of November 2020" ?
Use regular expressions matching. You can iterate the matches with prxNext:
data want;
if not prxId then prxId + prxParse("@\d\d?/\d\d?/\d\d(\d\d)?@");
set have;
start = 1;
stop = length(text);
call prxnext(prxID, start, stop, text, position, length);
do while (position > 0);
date = input(substr(text, position, length), ?? mmddyy10.);
if not missing(date) then output;
call prxnext(prxID, start, stop, text, position, length);
end;
keep date;
format date yymmdd10.;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.