BookmarkSubscribeRSS Feed
YadiAcho
Calcite | Level 5
Need help!!

I have data field look like this :

78687hkjkjh43@hsak-786778@hhjjjh762lkjklll

I want to get data beetween delimiter @.....@ I want get value hsak-786778
Thx for your help....

data getstr1(keep=memo test);
set Sastbl.sas;
test=input(delimiter="@" and "@",$10.);
run;

this can't solve my problem, any other solution please advice.thx....
4 REPLIES 4
Oleg
SAS Employee
Does not look nice, but formula should be
(SUBSTR(t1.A, Find(t1.a,'@')+1,Find(t1.a,'@',Find(t1.a,'@')+1)-Find(t1.a,'@')-1))

if You string contains in variable t1.A (I used EG for testing)
Hopefully You have not need to convert in this way million of rows.

P.S. I would add befoire this statement checks, that string really contains two pieces of @ sign.

/oleg
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello YadiAcho,

This is another solution:
[pre]
data a;
i="78687hkjkjh43@hsak-786778@hhjjjh762lkjklll";
r=SCAN(i,2,'@');
run;
[/pre]
Sincerely,
SPR
YadiAcho
Calcite | Level 5
thx...

it works...
ChrisHemedinger
Community Manager
And as a general-purpose pattern-matching approach, regular expressions work great. Check out the PRXMATCH function.

http://www2.sas.com/proceedings/sugi29/129-29.pdf

Chris
SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 933 views
  • 0 likes
  • 4 in conversation