BookmarkSubscribeRSS Feed
hellind
Quartz | Level 8

I have a dataset with Account Number that can be enrolled in a program. The data-set is monthly data. If it is enrolled the Enrolled_Flag = 1 else it is 0.

 

An account can only be enrolled at most once. How would I detect data issues with the file?

 

Account AAAA is okay, enrolled in second month.

Account_Number, Year_Month, Enrolled_Flag

AAAA, 202101, 0

AAAA, 202102,1

AAAA, 202103,1

 

 

Account BBBB is okay, enrolled and derollled in 4th month

Account_Number, Year_Month, Enrolled_Flag

1

1

1

0

 

Account CCC is okay always enrolled

1

1

1

1

 

Account DDDD is NOT okay, enrolled in 2nd month and then then enrolled in 4th month.

0

1

0

1

1

 

1 REPLY 1
s_lassen
Meteorite | Level 14

Something like this, I think:

data want;
  set have;
  by account enrolled notsorted;
  if first.account then
    n=enrolled;
  else if first.enrolled then
    n+enrolled;
  if last.account;
  if n>1 then
    flag='ERROR';
  else 
flag=' '; keep account flag; run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 285 views
  • 0 likes
  • 2 in conversation