BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10
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 DATAREQUIRED O/P
AUS Vs WIWI Vs AUS
IND Vs SRISRI Vs IND
AUS Vs WIWI Vs AUS
WI Vs AUSAUS Vs WI
IND Vs AUSAUS Vs IND
AUS Vs INDIND Vs AUS
SRI Vs INDIND Vs SRI
NZ Vs SASA Vs NZ
SA Vs NZNZ Vs SA
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

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;
BrahmanandaRao
Lapis Lazuli | Level 10

Thank you for solution

 

 

 

Regards,

ANAND

Kurt_Bremser
Super User

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;
BrahmanandaRao
Lapis Lazuli | Level 10

Thank you sir for your  support

 

 

Regards,

Anand

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 456 views
  • 1 like
  • 3 in conversation