BookmarkSubscribeRSS Feed
otis
Calcite | Level 5

This attribute, hist12, contains a 12-month history of delinquency. For example, 100000001000 indicates the most recent month and 9 months prior have delinquencies and all other months were current. I need to identify accounts with at least 1 delinquency in the last 12 months. What's the most efficient way to code it? I can use substr function to extract one byte at a time, but I would think there are better ways.

Thanks!

6 REPLIES 6
Reeza
Super User

Isn't that anything greater than 000000000000, 12 0's?

if hist12>'000000000000' then ...

otis
Calcite | Level 5

Thanks. That really helps. One thing I forgot to mention is that there is a value 'Z' represents inactivity. So it could look like: 10000zz00100. Your codes would include accounts with at least one delinquency in last 12 months or at least one inactivity ('Z') in last 12 months. How do I code it so I only have the first set?

Reeza
Super User

compress out the Z's....

Test is just to see the variable, you can delete that line.

data want;

set have;

test=input(compress(hist12, "z"), 12.);

if input(compress(hist12, "z"), 12.)>0 then flag=1;

else flag=0;

run;

Haikuo
Onyx | Level 15

If using compress() as Reeza suggested, you can as well just do the following:

data want;

  set have;

flag=lengthn(compress(a,'z0'))>0;

run;

Haikuo

Tom
Super User Tom
Super User

You could use the INDEXC() function or COUNTC() function.

if index(hist12, '1') then put 'Deliquent';

numdel = countc(hist12,'1');

firstdel = index(hist12,'1') ;

otis
Calcite | Level 5

Appreciate all the suggestions. They all worked. The easiest way in my situation is to use countc or index.

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
  • 6 replies
  • 882 views
  • 0 likes
  • 4 in conversation