BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
UcheOkoro
Lapis Lazuli | Level 10

I want to create a new variable(CC_new)  from a Chief Complaint variable (CC). The CC variable has  some observations with multiple Chief Complaints separated by a semicolon e.g. Headache;fever;sore throat. However, I only need the first Chief Complaint to create the CC_new variable.

Please, I need help with this.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
ketpt42
Quartz | Level 8
Semicolon is your delimiter, right? If so, use:
cc_new=scan(cc,1,';');

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

Is that what you are looking for?

cc_new = scan(cc,1,',');
UcheOkoro
Lapis Lazuli | Level 10

Thank you for your response. I tried the following but it did not help.

data Permanent_data3;
set Permanent_data;
cc_new = scan(cc,1,',');run;
ketpt42
Quartz | Level 8
Semicolon is your delimiter, right? If so, use:
cc_new=scan(cc,1,';');
UcheOkoro
Lapis Lazuli | Level 10

It worked. Thank you.

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
  • 4 replies
  • 919 views
  • 2 likes
  • 3 in conversation