Hi there,
I am trying to extract 'brown_fox' from the whole observation 'A_quick_brown_fox_01' with scan function. Can someone please help. The whole idea is to extract 3rd and 4th word separated by underscores.
Thanks,
data want;
str='A_quick_brown_fox_01' ;
length want $30;
do _i=3,4;
want=catx('_',want,scan(str,_i,'_'));
end;
drop _:;
run;
@mlogan wrote:
Hi there,
I am trying to extract 'brown_fox' from the whole observation 'A_quick_brown_fox_01' with scan function. Can someone please help. The whole idea is to extract 3rd and 4th word separated by underscores.
data abc;
string='A_quick_brown_fox_01_etc_etc_etc';
third=scan(string,3,'_');
fourth=scan(string,4,'_');
want = cats(third,'_',fourth);
run;
data want;
str='A_quick_brown_fox_01' ;
length want $30;
do _i=3,4;
want=catx('_',want,scan(str,_i,'_'));
end;
drop _:;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.