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

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 800 views
  • 0 likes
  • 3 in conversation