Hi I need to count in the data by patient ID where N=4
patientID | fREQ | STAT | FLAG |
1 | 4 | N | 4 |
1 | 4 | MIN | 1 |
1 | 4 | MAX | 1 |
1 | 4 | MEAN | 1 |
2 | 12 | N | 12 |
2 | 12 | MIN | 1 |
2 | 12 | MAX | 1 |
2 | 12 | MEAN | 1 |
3 | 4 | N | 4 |
3 | 4 | MIN | 1 |
3 | 4 | MAX | 1 |
3 | 4 | MEAN | 1 |
Assuming you want the count of the number of patient ids where the value of N is 4.
proc sql;
select count(*) from have
where stat='N' and flag=4
;
quit;
i I need to count in the data by patient ID where N=4
patientID | fREQ | STAT | FLAG |
1 | 4 | N | 4 |
1 | 4 | MIN | 1 |
1 | 4 | MAX | 1 |
1 | 4 | MEAN | 1 |
2 | 12 | N | 12 |
2 | 12 | MIN | 1 |
2 | 12 | MAX | 1 |
2 | 12 | MEAN | 1 |
3 | 4 | N | 4 |
3 | 4 | MIN | 1 |
3 | 4 | MAX | 1 |
3 | 4 | MEAN | 1 |
You've posted what looks like a dataset of the output of a SAS procedure.
How about posting some actual sample data? Are you simply wanting to select the items in a given data set that are in it 4 times?
proc sql;
select patientid, count(patientid)
from have
group by patientid
having count(patientid) = 4;
run;
Go back to your proc means step and use the ODS OUTPUT instead of the OUT data set, it's a cleaner format.
proc means data=sashelp.class nway stackods N MEAN MIN MAX ;
class sex;
var age;
ods output summary=want;
run;
proc print data=want;
run;
@centro_9 wrote:
Hi I need to count in the data by patient ID where N=4
patientID
fREQ
STAT
FLAG
1
4
N
4
1
4
MIN
1
1
4
MAX
1
1
4
MEAN
1
2
12
N
12
2
12
MIN
1
2
12
MAX
1
2
12
MEAN
1
3
4
N
4
3
4
MIN
1
3
4
MAX
1
3
4
MEAN
1
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Ready to level-up your skills? Choose your own adventure.