BookmarkSubscribeRSS Feed
ThomasRDaugaard
Calcite | Level 5

Hello people

 

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
5            Ascites

 

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 ;
run;

 

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

Thomas






 

4 REPLIES 4
Astounding
PROC Star

Not without jumping through some sort of hoop.  The easiest hoop to jump through is probably this one:

 

data temp;

set have;

if graft_comp1 > ' ' then do;

   complication = graft_comp1;

   output;

end;

if graft_comp2 > ' ' then do;

   complication = graft_comp2;

   output;

end;

if graft_comp3 > ' ' then do;

   complication = graft_comp3;

   output;

end;

run;

 

proc freq data=temp;

tables complication / nocum;

run;

 

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.

ThomasRDaugaard
Calcite | Level 5

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.

 

Thomas

Astounding
PROC Star

There is just one line that needs to change:

 

set have;

 

You have to plug in the name of your data set here.

TomKari
Onyx | Level 15

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.

 

Tom

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 1117 views
  • 0 likes
  • 3 in conversation