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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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