Hi Guys,
I need one minor help.
Below is my input data;
802,803 |
803,804 |
60,61 |
817,818 |
817,818,819 |
810,811,812 |
55,56 |
55,56,57 |
I want output like below;
803 |
804 |
61 |
818 |
818,819 |
811,812 |
56 |
56,57 |
I want to remove data comes before first comma.
How can I do this.
The following finds the first comma and then uses substr() to get the text after that:
data have;
input text : $char50.;
datalines;
802,803
803,804
60,61
817,818
817,818,819
810,811,812
55,56
55,56,57
;
data want;
set have;
text2 = substr(text,findc(text,',')+1);
run;
Kind regards,
Amir.
Your data is character, right?
yes
Do something like this
data have;
input value $ 1-20;
datalines;
802,803
803,804
60,61
817,818
817,818,819
810,811,812
55,56
55,56,57
;
data want;
set have;
value = prxchange("s/([^,]+),//", 1, value);
run;
Result:
value 803 804 61 818 818,819 811,812 56 56,57
The following finds the first comma and then uses substr() to get the text after that:
data have;
input text : $char50.;
datalines;
802,803
803,804
60,61
817,818
817,818,819
810,811,812
55,56
55,56,57
;
data want;
set have;
text2 = substr(text,findc(text,',')+1);
run;
Kind regards,
Amir.
Thank you so much ...
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.