02-02-2017 02:59 AM
I'm new with SAS and have just started using Enterprise Guide. I've got a bit stuck with the statistics and I hope you can help me.
A segment of my sheet looks something like this:
id graft_comp1 graft_comp2 graft_comp3
1 Ascites Rejection
2 Hypoalbuminemia Hypoalbuminemia
3 Hypoalbuminemia Ascites Ascites
4 Rejection Rejection
I would like to get the frequencies and percentages of each complication (after surgery) from all the columns. I have tried with this:
proc freq data=komplib.cdmerged;
tables graft_comp1 graft_comp2 graft_comp3 / nocum ;
But this way I get the data in tree different tables.
Is there any way I can get the results as a sum of all data in the columns collectively?
Plese helt me.
02-02-2017 06:22 AM
Not without jumping through some sort of hoop. The easiest hoop to jump through is probably this one:
if graft_comp1 > ' ' then do;
complication = graft_comp1;
if graft_comp2 > ' ' then do;
complication = graft_comp2;
if graft_comp3 > ' ' then do;
complication = graft_comp3;
proc freq data=temp;
tables complication / nocum;
If you have a large number of variables, not just 3, you don't have to spell out the logic for all of them. Instead, you could create an array in the DATA step, and process each variable in the array.
02-02-2017 07:24 AM
Thank you very much for your reply.
I will try if I can get it to work.
Should I just copy past your codes or is there any changes I need to make? I am very new with SAS so I might need some very specific directions.
02-02-2017 08:50 AM
There is just one line that needs to change:
You have to plug in the name of your data set here.
02-02-2017 11:08 AM
Another option is to use the Data > Transpose task in EG. Make sure your data is sorted by "id", and then put "id" in the "Group Analysis By" variable and the three "comp" variables in "Transpose Variables". Then you'll just need a quick query to eliminate the blank cells.