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

Dear SAS Experts

 

I want to select  all datalines based on highest numbermeet within record_id and admission_number . Normally I would just reverse sort and keep first;however I want to keep all lines that come from the last numbermeet so this does not work. Do you have any suggestion?

 

This is my data. See problem in lines two and three.

 

data have;input  Record_id  admission_number  (Admission_date Discharge_date date_of_diagnosis) (:ddmmyy10.)  diagnosis $;format Admission_date Discharge_date date_of_diagnosis ddmmyyd10. numbermeet;

 

datalines;

1 1 01-01-2010 01-02-2010 02-01-2010 df200 1

1 1 01-01-2010 01-02-2010 02-03-2010 df100 2

1 1 01-01-2010 01-02-2010 04-03-2010 df147 2

1 2 03-03-2010 31-03-2010 04-03-2010 df147 1

1 2 03-03-2010 31-03-2010 04-03-2010 df200 2

2 1 03-04-2010 31-08-2010 04-03-2010 df201 1 ;

 

run;

 

Kind regards Solvej

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You could do:

proc sql;
  create table want as 
  select *
  from  have
  group by record_id,admission_number
  having numbermeet=max(numbermeet);
quit;

 

View solution in original post

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You could do:

proc sql;
  create table want as 
  select *
  from  have
  group by record_id,admission_number
  having numbermeet=max(numbermeet);
quit;

 

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!

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
  • 609 views
  • 1 like
  • 2 in conversation