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-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!

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.

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