Help using Base SAS procedures

Chi Output Issue

Accepted Solution Solved
Reply
Regular Contributor
Regular Contributor
Posts: 238
Accepted Solution

Chi Output Issue

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;


Accepted Solutions
Solution
‎04-12-2012 03:31 PM
Regular Contributor
Regular Contributor
Posts: 238

Re: Chi Output Issue


All Replies
Solution
‎04-12-2012 03:31 PM
Regular Contributor
Regular Contributor
Posts: 238

Re: Chi Output Issue

found the answer

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 195 views
  • 0 likes
  • 1 in conversation