BookmarkSubscribeRSS Feed
QAMARSULTANA
Calcite | Level 5

How to write the code to remove loans that have payment Center that ends in 30 or 35 in SAS EG and also in SAS VA 

13 REPLIES 13
ChrisNZ
Tourmaline | Level 20

This entry enters the competition for shortest question.

 

One way:

where reverse(catt(CENTER)) not in: ('53','03')

 

 [Edited] colon added. Thanks @Astounding.

Astounding
PROC Star

This looks promising, but should add a colon:

 

where reverse(catt(CENTER)) not in : ('53','03')

Reeza
Super User
Is Payment Centre numeric or character? Are you programming or using the GUI.
QAMARSULTANA
Calcite | Level 5
It is numeric,
The code that I wrote was,
proc sql;
create table Sample as



select distinct
b.mktDesc,
a.acctno as Loan_Number ,
a.acctSName ,
a.balToday,
a.commitment,
a.TDR,
d.SICD ,
a.PD,
a.LGD,
a.pastDue,
a.user1 ,
c.offcrname,
a.timeid,
a.costCenter
from everest.loans a
left join everest.loanMaster b
on a.acctno = b.acctno
left join everest.loanOfficer c
on a.offcrCde = c.offcrid
left join WORK.sic d
on a.acctno=d.acctno
where a.timeid = "&CM."
and a.restructFlg = 'Y'



and a.commitment not in (0)
Order by a.commitment desc, a.baltoday desc;

quit;


But now I have too remove loans that have costCenter that ends in 20 or
25.

Help me out with this.
ballardw
Super User

When the value is numeric you would want

 

mod(variable,100) in (30 35)

 

the MOD function returns the remainder when dividing the variable by the second parameter

Reeza
Super User
Use PUT(varNAME, 8. -l) to convert it to a character.
ChrisNZ
Tourmaline | Level 20

The very first reply you got works for both numbers and strings.

Have you tried?

Oligolas
Barite | Level 11

Challenge accepted

where prxmatch("m/^.*(35|30)\s*$/",CENTER)=0;

 

or even

 

if prxmatch("m/^.*(35|30)\s*$/",CENTER)=0;

________________________

- Cheers -

Oligolas
Barite | Level 11

or

if ^prxmatch("/3[50] *$/",CENTER);

 

considering the new requirements:

^prxmatch("/2[50]$/",catt(CENTER));

________________________

- Cheers -

QAMARSULTANA
Calcite | Level 5
I get this error message


53 left join WORK.sic d
54 on a.acctno=d.acctno
55 where prxmatch("m/^.*(35|30)\s*$/",costCenter)=0
2 The SAS
System 20:56 Thursday, January 17, 2019
56
57 and a.timeid = "&CM."
58 and a.restructFlg = 'Y'
59
60
61 and a.commitment not in (0)
62 Order by a.commitment desc, a.baltoday desc;
ERROR: Function PRXMATCH requires a character expression as argument 2.
ERROR: Expression using equals (=) has components that are of different
data types.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 13 replies
  • 1473 views
  • 6 likes
  • 6 in conversation