BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ykoba
Fluorite | Level 6

I appreciate your help.

I have data set shown below.

ID time NIBP

1 1 89

1 2 90

1 3 78

1 4 87

1 5 88

1 6 89

1 7 90

2 1 77

2 2 88

2 3 90

3 1 99

3 2 100

 

I would like to count point  where NIBP=<88 for individual ID. I would like to acquire an output like,

 

ID count

1 3

2 1

3 0

 

In my actual data set, the number of ID is 18 thousands and the length of the time is different for each ID. 
Thank you very much for your kindness in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;
input ID time NIBP;
cards;
1 1 89
1 2 90
1 3 78
1 4 87
1 5 88
1 6 89
1 7 90
2 1 77
2 2 88
2 3 90
3 1 99
3 2 100
;

proc sql;
create table want as
select id, sum(NIBP le 88) as count
from have
group by id;
quit;

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

UNTESTED CODE

data have2;
     set have;
     if nibp<=88 then flag=1;
     else flag=0;
run;

proc summary nway data=have2;
    class id;
    var flag;
    output out=want sum=count;
run;

 

--
Paige Miller
ykoba
Fluorite | Level 6

Dear PaigeMiller,

I appreciate for your immediate reply.

I will try later the code you told me.

 

novinosrin
Tourmaline | Level 20
data have;
input ID time NIBP;
cards;
1 1 89
1 2 90
1 3 78
1 4 87
1 5 88
1 6 89
1 7 90
2 1 77
2 2 88
2 3 90
3 1 99
3 2 100
;

proc sql;
create table want as
select id, sum(NIBP le 88) as count
from have
group by id;
quit;
ykoba
Fluorite | Level 6

Dear novinosrin,

I really appreciate for your prompt replay.

The code you told me perfectly worked!

novinosrin
Tourmaline | Level 20

Thank you @ykoba  If you choose @PaigeMiller 's solution, then mark his solution as accepted or if you choose mine, mark mine as accepted and close the thread please

ykoba
Fluorite | Level 6

Dear novinosrin,

I really appreciate your kindness!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 6 replies
  • 908 views
  • 1 like
  • 3 in conversation