BookmarkSubscribeRSS Feed
tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

so now I am thinking I should just export the table and then manually do stuff in excel to make it look like the example I was provided and import to SAS but that I am sure that is not what past programmers in my company have done. I am sure they figured out a way to do it all in SAS and my boss has even said I should do this all in SAS but I am left to figure it out on my own and as we can see by my number of posts I am not able too. Have read tons of books and just spinning my wheels and wasting time. I have my meeting Friday to show my data but I am no where near able to do that unless I figure this out.

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

I think I got it. I played and played and this is the code I used:

proc sql;

create table chi4 as

select * from

(select distinct who as source, who, svcd, svdesc, admission, count from chi)

union all

(select distinct "national", a.who, b.svcd, b.svdesc, b.admission, b.count from

chi as a inner join chi3 as b

on a.svcd = b.svcd and

a.svdesc = b.svdesc and

a.admission = b.admission)

order by who, svcd, source, admission);

run;

The output chi4 table looks like this:

who        who          svcd           svdesc          admission             count

1111       1111          1             minor              no                   1

1111       1111          1             minor              yes                  0

national   1111          1             minor              no                  31645

national   1111          1             minor              yes                  52

2222       2222          2             moderate           no                   1

2222       2222          2             moderate           yes                  0

national   2222          2             moderate           no                  41864

national   2222          2             moderate           yes                  154

etc

Now I have to do a step to drop the 2nd who column or rename the label or something so when I do my chi it looks at the who with the numbers and national and then the remaining columns. Because if I use the 2nd column then it will add all the counts together. If I use first column it will chi it correctly from what I can tell.

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

I added a data step because even though the labels in the chi4 table both show who, the actual column name is source and who so I did this step:

data chi5 (drop = who);

set chi4;

run;

It drops the 2nd who column and leaves the other who column which is actually source and looks the way it should. So let me see how my chi works now.

mlamias
Fluorite | Level 6

Why on earth would you want to perform a Chi-Squared Test on a table with this many cells?

SteveDenham
Jade | Level 19

And with so many cells with virtually no representation (counts<2)?  A sensible aggregation seems in order here.

Steve Denham

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 2203 views
  • 0 likes
  • 6 in conversation