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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.