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
Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

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!

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