All,
I have created table 'duedatepop1' that contains 3 variables (case_identifier, duedatepop, and note). Note variable is one of two results:
Due Date changed from [empty] to [2020-03-01 00:00:00]
-OR-
Due Date changed from [11/23/2019 12:00 AM] to [2020-04-27 00:00:00]
I am needing to parse the date from the second set of brackets into a new table with the same variables in addition to the new date field (duedate), but I've not been able to do so. I'm not sure if the brackets are causing an issue or not. Thanks in advance for any and all assistance rendered.
I am interpreting this as that you have SAS data set with a character variable holding text as shown.
If, and this a moderately big if , all the text has exactly two sets of values inside [] and at least one word or space between them the following may help:
data example; x ="Due Date changed from [11/23/2019 12:00 AM] to [2020-04-27 00:00:00]"; date = input( scan (x,4,'[]'),yymmdd10.); format date date9.; run;
I am assuming that you wanted an actual SAS date value and use the DATE9 format just to show the date is such. Pick your own format.
What code you tried ? and what issues you had?
Please post
(1) a sample of data
(2) the full log (code + messages) of your run
(3) show what result you expect.
I am interpreting this as that you have SAS data set with a character variable holding text as shown.
If, and this a moderately big if , all the text has exactly two sets of values inside [] and at least one word or space between them the following may help:
data example; x ="Due Date changed from [11/23/2019 12:00 AM] to [2020-04-27 00:00:00]"; date = input( scan (x,4,'[]'),yymmdd10.); format date date9.; run;
I am assuming that you wanted an actual SAS date value and use the DATE9 format just to show the date is such. Pick your own format.
Minor adjustment, but it worked!
data duedatepop2;
set work.duedatepop1;
duedate = input(scan(note,4,'[]'),yymmdd10.);
format duedate date9.;
drop note;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.