BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
r3570
Obsidian | Level 7

Dear All,

 

I have below dataset where few records in TERM column have more than 1 word. I need to identify such records and flag them

 

ID          TERM

101       VOMITING

101       HEADACHE and NAUSEA

102       FATIGUE

102       PYREXIA/COLD

 

My output should be as below:

 

ID          TERM                                     FLAG

101       VOMITING

101       HEADACHE and NAUSEA        Y

102       FATIGUE

102       PYREXIA/COLD                         Y

 

Please help.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input ID TERM $ 5 - 25; 
datalines;
101 VOMITING
101 HEADACHE and NAUSEA
102 FATIGUE
102 PYREXIA/COLD
;

data want;
   set have;
   flag = ifc(countw(term, ' /') > 1, 'Y', '');
run;

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input ID TERM $ 5 - 25; 
datalines;
101 VOMITING
101 HEADACHE and NAUSEA
102 FATIGUE
102 PYREXIA/COLD
;

data want;
   set have;
   flag = ifc(countw(term, ' /') > 1, 'Y', '');
run;

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 299 views
  • 0 likes
  • 2 in conversation