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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1105 views
  • 0 likes
  • 3 in conversation