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

Hi Guys . I am only interested in the underlined digits. I have tried with the compress and substr but no luck.


Example of data;

P2Pb 430 041017
P2P 10538 030517 DIBS
P2P 496 01092017
P2P 2594 01112016

thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26
data want;
  set have;
  want=input(scan(thedata,2," "),best.);
run;

Note I assume your data is called have and the variable is thedata.

Post test data in the form of a datastep in the post using a code window, we cannot guess!!!! 

View solution in original post

2 REPLIES 2
error_prone
Barite | Level 11

Please post the code you tried, so that it is easier to suggest corrections. You can use the scan-function to get the second part of the string, then use the input-function to convert the extract to a number.

RW9
Diamond | Level 26 RW9
Diamond | Level 26
data want;
  set have;
  want=input(scan(thedata,2," "),best.);
run;

Note I assume your data is called have and the variable is thedata.

Post test data in the form of a datastep in the post using a code window, we cannot guess!!!! 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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