BookmarkSubscribeRSS Feed
shuchidxt_gmail_com
Obsidian | Level 7

how to substr any character string which will consider all spaces and special characters in the fields.

 

I have to substr a field  to 200 character which will consider all spaces and special characters in the sting.

 

Currently I just used length=200 for the field but it had created string with more than 200 length of characters by putting "" double quotes twice to the string as example below. I suppose I Need to use substr function to do this?

 

Example :

No wire activity was identified during an extended search from July-September 2018. 
BAU All Trans report  identified minimal activity; of note was a debit for $100K stating "OFAC/Funds moved to Omnibus". UAR# xxxx


"No wire activity was identified during an extended search from July-September 2018. 
BAU All Trans report  identified minimal activity; of note was a debit for $122K stating ""OFAC/Funds moved to Omnib"

2 REPLIES 2
ballardw
Super User

@shuchidxt_gmail_com wrote:

how to substr any character string which will consider all spaces and special characters in the fields.

Consider them for what purpose?

It is not very clear what you are attempting to actually accomplish.

 

Best is to clearly show a start value and the desired result, ideally in the form of data step code for the starting values.

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Astounding
PROC Star
You haven't shown what you tried already, so this might be a possibility:

length newvar $ 200;
newvar = oldvar;

There's only room to store 200 characters, so SAS really has no choice about what it should do.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 439 views
  • 0 likes
  • 3 in conversation