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
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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