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

My chi code looks like this:

proc freq data = chi4 noprint;

by who svcd svdesc;

tables source*admission / chisq;

weight count;

output out = chifinal;

run;

My output is this:

who         svcd     svdesc       numsubstrata            chisquare       more columns but not the problem

1111          1       minor               31698

1111          2       moderate          42019

That above is not the correct output. The table chi4 from above has this information in it:

source          who           svcd          sbvdesc          admission      count

national        1111            1               minor               no                 31645

national        1111            1               minor               yes                     52

prov_tin        1111            1               minor               no                         1

prov_tin        1111            1               minor               yes                        0

national        1111            2             moderate           no                 41864

national        1111            2             moderate           yes                   154

prov_tin        1111            2             moderate           no                         1

prov_tin        1111            2             moderate           yes                        0

So the code I have above is actually combining all the items under the who and the svcd and summing the no and yes. That is not what I want I want the output to be

who               svcd                     svcdesc                admission             count

national           1                         minor                       no                     31645

1111               1                         minor                       no                            1

national           1                         minor                     yes                           52

1111               1                         minor                     yes                             0

national           2                       moderate                   no                        41864

1111               2                       moderate                   no                             1

national          2                       moderate                  yes                           154

1111              2                       moderate                  yes                              0

Then it will calculate the rest of the chi information. It just has to do with something I am not doing with the source portion and the who. If it helps here is my code to combine the who and source and get the national data into the information with the tin data.

proc sql;

create table chi4 as

select * from

(select distinct "prov_tin" as source, who, svcd, svcdesc, admission, count from chi)

union all

(select distinct "national", a.who, a.svcd, a.svcdesc, a.admission, a.count from chi as inner join chi3 as b

on a.svcd = b.svcd and

a.svcdesc = b.svcdesc and

a.admission = b.admission)

order by who, svcd, source, admission;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
tmm
Fluorite | Level 6 tmm
Fluorite | Level 6
1 REPLY 1
tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

found the answer

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
  • 1 reply
  • 659 views
  • 0 likes
  • 1 in conversation