Hi
I have a string variable that sometimes contains a date in the same format (DD Mon YY). The rest of the string differs.
Do you have any tips on how to extract this date? I was thinking along the lines of finding the first number & then extracting the number of characters, or using regular expressions for the date format, but I haven't managed to succeed yet.
In the dataex example below, "status" shows examples of the string variable & "desiredvar" shows what I would like to extract.
Any pointers would be greatly appreciated!
I have a string variable that sometimes contains a date in the same format (DD Mon YY). The rest of the string differs.
Do you have any tips on how to extract this date? I was thinking along the lines of finding the first number & then extracting the number of characters, or using regular expressions for the date format, but I haven't managed to succeed yet.
In the dataex example below, "status" shows examples of the string variable & "desiredvar" shows what I would like to extract.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str40 status str9 desiredvar float date "Ongoing: stopped on 03 Feb 21" "03 Feb 21" 22314 "N/A" "" . "Discontinued 06 Apr 21 - LTFU" "06 Apr 21" 22376 "N/A" "" . "N/A" "" . "Ongoing: stopped on 12 May 21" "12 May 21" 22412 "N/A" "" . "Discontinued 16 Apr 21 - ran out" "16 Apr 21" 22386 "Ongoing: stopped on 08 Apr 21" "08 Apr 21" 22378 "Ongoing: stopped on 06 Jul 21" "06 Jul 21" 22467 "Discontinued 06 Apr 21 (adverse event)" "06 Apr 21" 22376 "Ongoing: stopped on 23 Nov 21 (EOS)" "23 Nov 21" 22607 end format %td date
Comment