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
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Select SAS Training centers are offering in-person courses. View upcoming courses for: