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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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