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 |
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.
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.
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.
Ready to level-up your skills? Choose your own adventure.