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.
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!
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.
Ready to level-up your skills? Choose your own adventure.