BookmarkSubscribeRSS Feed
centro_9
Calcite | Level 5

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

5 REPLIES 5
Tom
Super User Tom
Super User

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;
centro_9
Calcite | Level 5

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

HB
Barite | Level 11 HB
Barite | Level 11

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;

 

 

Reeza
Super User

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


 

Reeza
Super User
Please do not post the same question multiple times.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 5 replies
  • 482 views
  • 0 likes
  • 4 in conversation