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

Hello everyone,

 

We want to capture symbol "&" from libname statement form user information along with username. As of now whole username is coming properly, but symbol & is not coming. We have used SAS character functions such as substr, find & scan to capture this. 

Please look into below snippet for more clarity. 

devi001_1-1679905781584.png

 

Please help to capture "&" from user= from libname statement.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

Don't know if this is bullet proof, and there may be more elegant solutions:

scan(substr(a,findw(a, 'user', "'=")+4), 1, '=. ')
Data never sleeps

View solution in original post

7 REPLIES 7
LinusH
Tourmaline | Level 20

What is the context - where, when and how do you wish to capture this?

Data never sleeps
devi001
Obsidian | Level 7

In SAS dataset, new column

Kurt_Bremser
Super User

Please post data as text, not in pictures. We can't copy pictures into the program editor window, but text works perfectly fine 😉

If you already have a dataset containing this information, please post it in a data step with datalines.

devi001
Obsidian | Level 7

Apologies. Please find attached snippet of sample dataset. Requirement is in user column "&" should also come. 

PaigeMiller
Diamond | Level 26

No snippet attached.

--
Paige Miller
LinusH
Tourmaline | Level 20

Don't know if this is bullet proof, and there may be more elegant solutions:

scan(substr(a,findw(a, 'user', "'=")+4), 1, '=. ')
Data never sleeps
devi001
Obsidian | Level 7

Thank you! It worked well.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 1188 views
  • 0 likes
  • 4 in conversation