An example of the string is below, how do I remove the TXX:XX:XX+XX:XX part of the string. I want to make it as dynamic as possible. Examples of how the string may appear in my data.
{"VariableA":"1","VaraibleB":"1","VariableC":"1","VariableD":"2023-01-02T13:30:10+00:00","VariableE":"1"}
{"VariableA":"1","VaraibleB":"1","VariableC":"1","VariableD":"","VariableE":"1"}
{"VariableA":"1","VaraibleB":"1","VariableD":"2023-01-02T13:30:10+00:00","VariableC":"1","VariableE":"1"}
cheers
A RegEx should do.
data have;
infile datalines truncover;
input have_str $300.;
datalines4;
{"VariableA":"1","VaraibleB":"1","VariableC":"1","VariableD":"2023-01-02T13:30:10+00:00","VariableE":"1"}
{"VariableA":"1","VaraibleB":"1","VariableC":"1","VariableD":"","VariableE":"1"}
{"VariableA":"1","VaraibleB":"1","VariableD":"2023-01-02T13:30:10+00:00","VariableC":"1","VariableE":"1"}
;;;;
data want;
set have;
length want_str $300;
want_str=prxchange('s/T\d\d:\d\d:\d\d\+\d\d:\d\d//oi',-1,trim(have_str));
run;
You can help us help you if you post sample data via a working SAS data step as done above with data have and then also show us a concrete desired result based on the sample data provided.
A RegEx should do.
data have;
infile datalines truncover;
input have_str $300.;
datalines4;
{"VariableA":"1","VaraibleB":"1","VariableC":"1","VariableD":"2023-01-02T13:30:10+00:00","VariableE":"1"}
{"VariableA":"1","VaraibleB":"1","VariableC":"1","VariableD":"","VariableE":"1"}
{"VariableA":"1","VaraibleB":"1","VariableD":"2023-01-02T13:30:10+00:00","VariableC":"1","VariableE":"1"}
;;;;
data want;
set have;
length want_str $300;
want_str=prxchange('s/T\d\d:\d\d:\d\d\+\d\d:\d\d//oi',-1,trim(have_str));
run;
You can help us help you if you post sample data via a working SAS data step as done above with data have and then also show us a concrete desired result based on the sample data provided.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.