DATA Step, Macro, Functions and more

Repeated measure to be sorted by three variable and select minimum by a variable

Accepted Solution Solved
Reply
Super Contributor
Posts: 324
Accepted Solution

Repeated measure to be sorted by three variable and select minimum by a variable

Hello,

 I have this data that I want to sort by SID New_dt and NIPR.

For each subject I want just the minimum NPIR for that day. I also want to delete all observations with missing NPIR

For example this data should be reduced to Data A below:

Obs

SID

New_dt

NPiR

1

10155

.

.

2

101004

10/06/15

.

3

101004

10/14/15

4.2

4

101004

10/16/15

4.5

5

101004

10/19/15

4.1

6

101004

10/19/15

4.3

7

101004

10/19/15

4.6

8

101023

11/03/15

.

9

101023

11/05/15

4.2

10

101023

11/06/15

1.3

11

101023

11/07/15

3.8

12

101023

11/07/15

2.4

 

Should be reduced TO  Data A :

 

3

101004

10/14/15

4.2

4

101004

10/16/15

4.5

5

101004

10/19/15

4.1

9

101023

11/05/15

4.2

10

101023

11/06/15

1.3

12

101023

11/07/15

2.4

 

 

 

 


Accepted Solutions
Solution
‎04-11-2018 04:45 PM
Super User
Posts: 6,632

Re: Repeated measure to be sorted by three variable and select minimum by a variable

[ Edited ]
Posted in reply to desireatem

A one-step way:

 

proc summary data=have nway;

where npir > .;

class sid new_dt;

var npir;

output out=want (drop=_type_ _freq_) min=;

run;

 

If your actual data set contains additional variables, it becomes more problematic and we'd have to examine some of the details within the data.

View solution in original post


All Replies
Solution
‎04-11-2018 04:45 PM
Super User
Posts: 6,632

Re: Repeated measure to be sorted by three variable and select minimum by a variable

[ Edited ]
Posted in reply to desireatem

A one-step way:

 

proc summary data=have nway;

where npir > .;

class sid new_dt;

var npir;

output out=want (drop=_type_ _freq_) min=;

run;

 

If your actual data set contains additional variables, it becomes more problematic and we'd have to examine some of the details within the data.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 89 views
  • 1 like
  • 2 in conversation