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 Innovate 2025: Call for Content! Submit your proposals before Sept 16. Accepted presenters get amazing perks to attend the conference!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 981 views
  • 0 likes
  • 4 in conversation