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
SAS Super FREQ
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

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!

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