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 2025: Register Now

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!

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 899 views
  • 0 likes
  • 4 in conversation