BookmarkSubscribeRSS Feed
ren2010
Obsidian | Level 7
Hello all,

I am a situation where i have dataset with two variables name and alias:

Name Alias
xxx_999_aa 999
vvv_156_bb 156

My requirement is to find the alias in the name,so as per below i need to find if 999 or 156 is present in names.I tried using the FIND function like the following;

data test;
set a;
x=find(name,alias);
if x > 0 then delete;
run;
but this does not seems working as the value of the x is getting assigned as 0.

Please help
3 REPLIES 3
Reeza
Super User
The alias might have trailing or leading blanks, and then you're searching for
' 999' or '999 ' rather than 999.

Try using the compress function on alias:


x=find(name, compress(alias));
y=find(name, alias);
Doc_Duke
Rhodochrosite | Level 12
without your log and contents it is hard to pinpoint. Some suggestions.

-- Make sure both variables are character.
-- Make sure the alias does not have either leading or trailing blanks in it (print alias with a hex format to see what SAS thinks is there).
-- You might try the code
x=find(name,trim(left(alias)));
to see if that helps.

Doc Muhlbaier
Duke
ren2010
Obsidian | Level 7
Thank you all

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 995 views
  • 0 likes
  • 3 in conversation