BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RobF
Quartz | Level 8

I'm using "by group" processing for a healthcare claims dataset containing records sorted by member ID and service date to determine eligibility for my analysis dataset.

Once I've determined if a particular member is eligible or ineligible, I output the member ID and an eligibility flag to a dataset and then no longer need to process the rest of the claim records for that member.

How can I skip to the first claim for the next member in the dataset? I've tried RETURN, STOP and LEAVE statements with limited success.

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

This skips (if then delete) additional processing for the by group once ELIG is true.  The ELIG criteria in my example is N eq 2;

proc sort data=sashelp.class out=class;
   by sex;
   run;
proc print;
  
run;
data elig;
   set class;
   by sex;
   if not first.sex and elig then delete;
   retain elig 0;
  
if first.sex then do;
      elig =
0;
     
x = 0;
     
end;
   x +
1;
  
if x eq 2 then do;
      elig =
1;
     
output;
     
end;
  
run;
proc print;
  
run;

  

View solution in original post

4 REPLIES 4
Haikuo
Onyx | Level 15

If you are using 'by group' processing, the simple answer is 'No'. The only way to skip obs in data step is to use point=, but then it is not compatible with 'by group'.

You maybe able to do it using a Hash object, but then you need to read in all of the obs into Hash first, beat the purpose anyway.

Good Luck,

Haikuo

data_null__
Jade | Level 19

This skips (if then delete) additional processing for the by group once ELIG is true.  The ELIG criteria in my example is N eq 2;

proc sort data=sashelp.class out=class;
   by sex;
   run;
proc print;
  
run;
data elig;
   set class;
   by sex;
   if not first.sex and elig then delete;
   retain elig 0;
  
if first.sex then do;
      elig =
0;
     
x = 0;
     
end;
   x +
1;
  
if x eq 2 then do;
      elig =
1;
     
output;
     
end;
  
run;
proc print;
  
run;

  
Astounding
PROC Star

Just a matter of style and possibly readability ... I would replace the last 4 lines of the DATA step with 2 lines:

if x eq 2;

elig = 1;

As always, beauty is in the eye of the beholder.

RobF
Quartz | Level 8

Thank you, this was very helpful!

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
  • 4 replies
  • 2947 views
  • 3 likes
  • 4 in conversation