BookmarkSubscribeRSS Feed
keen_sas
Quartz | Level 8

Hi ,

 

The text that is present in square/Angular brackets are mostly considered as VARIABLE NAME, but in certain scenarios the plain text is also placed in square brackets to emphasize it.So in the code while concatenating the variable names are concatenated and converted into actual values present in that variable. The plain text that is placed in square brackets which is not variable
should be placed as it is in the text . 

 

For example in the second row entire text is placed in square brackets , it should be kept as it is without processing.

In the third row new technology in K-12 classroom is placed in square brackets , this should be unprocessed.

 

As per my thoughts all variable names are single word and free text placed in square brackets are more than a word. How to handle such scenarios.

 

Have  Want 
The subject experienced [AESER] adverse event of [AESEV] intensity, reported as '[VBA]' ([LLT]). The subject experienced serious adverse event of severe intensity, reported as 'headache' (value]).
[Samsung - the first major smartphone maker to release a foldable smartphone] [Samsung - the first major smartphone maker to release a foldable smartphone]
School districts across the [COUNTRY] are on the cusp of integrating [new technology in K-12 classrooms] by exploring unexpected [CURRICULUM]
such as [SOCIAL_MEDIA] use as early as preschool.
School districts across the US are on the cusp of integrating [new technology in K-12 classrooms] by exploring unexpected Response
such as Facebook/Twitter use as early as preschool.

 

i am using the below code 
data want;
length sentence $500.;
set have ;
sentence='"'||tranwrd(sentence,'[', '"|| strip(');
sentence=tranwrd(sentence,']', ') ||"');
sentence=strip(sentence)||'"';
run ;

 

After conversion it looks like below , it converts the free text placed in square brackets, it should be avoided.

"The subject experienced" ||strip(AESER)|| "adverse event of" ||strip(AESEV) ||"intensity, reported as" ||'strip(VBA)' ||strip'(LLT)'".
"strip(Samsung - the first major smartphone maker to release a foldable smartphone)"
"School districts across the" ||strip(COUNTRY)|| "are on the cusp of integrating strip(new technology in K-12 classrooms )by exploring unexpected" ||strip(CURRICULUM)
"such as" ||strip(SOCIAL_MEDIA)|| "use as early as preschool."

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

You need to loop through the string and test the value in brackets.

Function  anyname()  will tell you whether to surround the bracketed value with  strip()  or to leave it alone.

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

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1067 views
  • 0 likes
  • 2 in conversation