BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kjohnsonm
Lapis Lazuli | Level 10

Hello all,

I have two Data Bases that store a field room, one has it with leading zeros and one without, the hitch is these rooms can have a alpha charater?   any ideas?

I had some 1100 false positives now with this just a 100 or so

 

I came up with this:

put(input(a.room,best4.),z4.) <> put(input(b.room,best4.),z4.)

 

I started with:

a.room <> b.room

but with data like:

 

a.room     b.room

451a        0451a

451b        0451b

1              00001

21            00021

1-1           001-1

 

 

 

I am not sure what to try to get them down to the true diffences that I want.  TIA   -KJ

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

PRX functions can be handy,

data have;
input aroom$     broom$;
_b=prxchange('s/(^0*)([^0]+.+)/$2/o',-1,broom);
equal_or_not=ifc(aroom=_b,'Y','N');
cards;
451a        0451a
451b        0451b
1              00001
21            00021
1-1           001-1
451a        0451c
;


View solution in original post

6 REPLIES 6
Haikuo
Onyx | Level 15

PRX functions can be handy,

data have;
input aroom$     broom$;
_b=prxchange('s/(^0*)([^0]+.+)/$2/o',-1,broom);
equal_or_not=ifc(aroom=_b,'Y','N');
cards;
451a        0451a
451b        0451b
1              00001
21            00021
1-1           001-1
451a        0451c
;


kjohnsonm
Lapis Lazuli | Level 10
Sorry I did not say it but my comparison I was using is in a proc sql where, I will check out your function. I hope it works in a proc sql.
Ksharp
Super User
data have;
input aroom$     broom$;
equal_or_not=(aroom=prxchange('s/^0+//',-1,broom));
cards;
451a        0451a
451b        0451b
1              00001
21            00021
1-1           001-1
451a        0451c
;
run;

kjohnsonm
Lapis Lazuli | Level 10
Both answers work equally well for my needs tie goes to the first response. thanks for your pointer on "prxchange"
Reeza
Super User

Just a check, but You know that <> is max in SAS?

In most languages it means Not Equals and from your usage it looks like that's what your using it for?  

 

The MIN and MAX operators are used to find the minimum or maximum value of two quantities. Surround the operators with the two quantities whose minimum or maximum value you want to know. The MIN (><) operator returns the lower of the two values. The MAX (<>) operator returns the higher of the two values.

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm

kjohnsonm
Lapis Lazuli | Level 10

Yes I am aware that <> is max, but in "proc sql" it works and works with SQL queries diectly thus we use it...   I have been burned by it in data steps so it is playing a bit with fire. 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 12026 views
  • 7 likes
  • 4 in conversation