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;
found the answer
found the answer
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.