BookmarkSubscribeRSS Feed
JatinBansal
Calcite | Level 5

Hi

I think following is the simplest thing we can do to get the required:

data new;

input text $50.;

datalines;

1.YOUR NAME IS 'SANJEEV.'

2.YOUR NAME IS 'SRINATH.'

333.Your name is anything.

;

data this;

set new;

text2 = substr(text, find(text,'.')+1);

run;

KarthikSrivasthav
Calcite | Level 5

Which word u want in the above example


Peter_C
Rhodochrosite | Level 12

I would use verify() to locate the first character of the name like

namepart = substr( text, verify( text, '0123456789 .' ));

yaswanthj
Fluorite | Level 6

Hi Sanjeev,

This code may will help you..

data have;

input number text&$30.;

cards;

1 1.YOUR NAME IS 'SANJEEV.'

2 2.YOUR NAME IS 'SRINATH.'

;

run;

proc print;

run;

data want;

set have;

/*text=compress(text,'.','d');*/

text =substr(strip(text),indexc(text ,'.')+1,length(text )-indexc(text ,'.'));

proc print;run;

Thanks,

Yaswanth J.

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!

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
  • 18 replies
  • 1790 views
  • 6 likes
  • 7 in conversation