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