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

/*********************************GET TINS WITH TOTAL ADMISSIONS >=10 ONLY*********************/

PROC SQL;

CREATE TABLE ReAdm.TIN_Merge3 AS

(SELECT *

FROM ReAdm.TIN_Merge2

WHERE ADMIT >=10

GROUP BY TIN);

RUN;

I need to code this to grab all my severities. Right now it will only grab those that have admit >=10 and my example table looks like this

who              svrty              admit

1111              1                    5

1111              2                    4

1111              3                   12

1111              4                    7

If I run the code above it only returns the svrty 3 and I need it actually to return all because the admits summed together are 28. I guess I need to code it where the sum of admit >=10 so it will return all svrty items.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

try:

PROC SQL;

CREATE TABLE ReAdm.TIN_Merge3 AS

  SELECT *

  FROM ReAdm.TIN_Merge2

  where tin in (select tin from ReAdm.TIN_Merge2

  GROUP BY TIN

  having sum(ADMIT) >=10)

;

quit;

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

PROC SQL;

CREATE TABLE ReAdm.TIN_Merge3 AS

  SELECT *

  FROM ReAdm.TIN_Merge2

  GROUP BY TIN

  having sum(ADMIT) >=10

;

RUN;

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

That does not return anything other than

who        svrty             admit

1111         3                  12

It leaves out the other svrty codes which I need them to be returned. A case where it would not be returned is this:

who         svrty          admit

2222          1              1

2222          2              3

2222          3              0

2222          4               0

None of these would be returned because the sum of the admit is not >=10 it is 4

I need all severities returned if the who has an admit sum of >=10 so in my first example all 4 severities should be returned because the sum of the TIN is 28

Tom
Super User Tom
Super User

From your example data your group by variable should be WHO not TIN.

Linlin
Lapis Lazuli | Level 10

try:

PROC SQL;

CREATE TABLE ReAdm.TIN_Merge3 AS

  SELECT *

  FROM ReAdm.TIN_Merge2

  where tin in (select tin from ReAdm.TIN_Merge2

  GROUP BY TIN

  having sum(ADMIT) >=10)

;

quit;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1026 views
  • 0 likes
  • 3 in conversation