BookmarkSubscribeRSS Feed
deleted_user
Not applicable
data abc;
address1='201 London fly';
run;
data abc;
set abc;
address=tranwrd(address1,'fly','drive');
run;


ques: what will be the length and value of variable 'address' in data set abc;

in notes i found answer like length=200 and value is '201 London drive'.....please ensure it is right...what you think abt the answer..tell me
2 REPLIES 2
andreas_lds
Jade | Level 19
Reading the online documentation for the transwrd function I found two import sentences:
"If the TRANWRD function returns a value to a variable that has not yet been assigned a length, by default the variable is assigned a length of 200."
and
"The value that the TRANWRD function returns has a default length of 200. You can use the LENGTH statement, before calling TRANWRD, to change the length of the value."
BSHARMA
Calcite | Level 5

While running the following program, the result from  proc print & proc content:  for  'address' length is 200 & value is '201 London drive' as well as for 'address1' length is 14 & value is '201 London fly'.

 

data abc;
address1='201 London fly';
run;
data abc;
set abc;
address=tranwrd(address1,'fly','drive');
run;

proc print data=abc;
run;
proc contents data=abc;
run;

 

 

 

SAS Output

Obs address1 address 1
201 London fly201 London drive

 

SAS Output

Alphabetic List of Variables and Attributes # Variable Type Len 2 1
addressChar200
address1Char14

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4285 views
  • 0 likes
  • 3 in conversation