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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 1 reply
  • 719 views
  • 0 likes
  • 2 in conversation