BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I'm trying to take this code and do it in one shot. Instead of check 3 seperate times I want to know if it's possible to do it all in one line.

data temp;
length a b c 8 ;

a= 1 ;
b= 1 ;
c= 1 ;

if ( find(upcase(addr),'PO') > 0 ) Then a = 0 ;
if ( find(upcase(addr),'P O') > 0 ) Then b= 0 ;
if ( find(upcase(addr),'P.O.') > 0 ) Then c= 0 ;

run;


Thank you for any help
Jerry
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The COMPRESS function comes to mind (to squeeze out unwanted characters within your test), given the limited example and conditions you have shown in your post.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Thanks for the tip. It helped me clean it up.
Cynthia_sas
Diamond | Level 26
Hi:
Other considerations might be whether you want to search for PO or P.O. within the first 4 or 5 characters of the address or anywhere in the address. For example:
[pre]
P.O. Box 66
PO 333
P O 222
1234 Rumpole St
4567 Popopo Blvd.
[/pre]

You would probably want the first 3, but not the last 2 (if you're looking for PO boxes). In which case, the SUBSTRING function might help limit the search to the first 4 or 5 characters of the address.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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