DATA Step, Macro, Functions and more

subtring on a variable length field

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

subtring on a variable length field

Hi

 

I am looking to grab the first few positions of a field before the '*" but as you can see the * is not in the same position of every record. I just want what is BEFORE the * 

 

Below are sample records - not sure if a substring would work and if so how?

 

example

 

card id

12345*companyname

1234*companyname

99999999*companyname

22*companyname


Accepted Solutions
Solution
‎05-16-2018 09:52 AM
Super User
Posts: 9,923

Re: subtring on a variable length field

newfield = scan(oldfield,1,"*");
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
‎05-16-2018 09:52 AM
Super User
Posts: 9,923

Re: subtring on a variable length field

newfield = scan(oldfield,1,"*");
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 30

Re: subtring on a variable length field

Posted in reply to KurtBremser
thank you!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 101 views
  • 1 like
  • 2 in conversation