data s ;
name='sas programmer ' ;
run;
how to insert 'H' in name variable see like below?
Note: without using tranwrd function,substr function
name |
sas proHgrammer |
Hello,
What is the ultimate goal and why the relevant tools should be forbidden ?
What criterion does tell us where the letter should be inserted ?
This does what you want but I doubt it really answers your needs.
data s ;
name='sas programmer ' ;
name2=cats(scan(name,1,'g'),'Hg',scan(name,2,'g'));
run;
Why can you not use the functions designed to manipulate strings? To put it another, your not allowed to use the keyboard, now type your messages in - doesn't make any sense right?
Anyways, you would have to loop over the array of characters manually, see below code:
data s; /* Note you have to assign a length which is greater than the string length + 1 other wise there will be truncation */ length name new_name $200; name='sas programmer '; do i=1 to lengthn(name); if char(name,i-1)=" " then new_name=cat(strip(new_name)," ",char(name,i)); else new_name=cats(new_name,char(name,i)); if i=7 then new_name=cats(new_name,"H"); end; run;
You can sees how much of a waste of time that is!
And please remember to mark all questions with answered when you have your answer.
And please use the code window - its the {i} above post area - to post code.
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 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: