data test;
infile datalines;
input Match $12.;
datalines;
AUS Vs WI
IND Vs SRI
AUS Vs WI
WI Vs AUS
IND Vs AUS
AUS Vs IND
SRI Vs IND
NZ Vs SA
SA Vs NZ
;
run;
Required Output like below
GIVEN DATA | REQUIRED O/P |
AUS Vs WI | WI Vs AUS |
IND Vs SRI | SRI Vs IND |
AUS Vs WI | WI Vs AUS |
WI Vs AUS | AUS Vs WI |
IND Vs AUS | AUS Vs IND |
AUS Vs IND | IND Vs AUS |
SRI Vs IND | IND Vs SRI |
NZ Vs SA | SA Vs NZ |
SA Vs NZ | NZ Vs SA |
Do like this
data test;
infile datalines;
input Match $12.;
datalines;
AUS Vs WI
IND Vs SRI
AUS Vs WI
WI Vs AUS
IND Vs AUS
AUS Vs IND
SRI Vs IND
NZ Vs SA
SA Vs NZ
;
run;
data test2;
set test;
name=prxchange('s/(\w+) Vs (\w+)/$2 Vs $1/', -1, Match);
run;
Do like this
data test;
infile datalines;
input Match $12.;
datalines;
AUS Vs WI
IND Vs SRI
AUS Vs WI
WI Vs AUS
IND Vs AUS
AUS Vs IND
SRI Vs IND
NZ Vs SA
SA Vs NZ
;
run;
data test2;
set test;
name=prxchange('s/(\w+) Vs (\w+)/$2 Vs $1/', -1, Match);
run;
Thank you for solution
Regards,
ANAND
Or this:
data have;
infile datalines;
input Match $12.;
datalines;
AUS Vs WI
IND Vs SRI
AUS Vs WI
WI Vs AUS
IND Vs AUS
AUS Vs IND
SRI Vs IND
NZ Vs SA
SA Vs NZ
;
run;
data want;
set have;
match = catx(' ',scan(match,3),scan(match,2),scan(match,1));
run;
Thank you sir for your support
Regards,
Anand
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.