Search code examples
sasproc

Add row percentage within top column in proc tabulate (SAS)


I am using Proc tabulate in SAS and I want to make a table like this example:enter image description here

As you can see, I want to calculate the rowpctn within each year. My problem is that i don't know where to write the rowpctn in the code, and after searching the web for an hour, I still haven't been able to find the answer.

My code looks like this:

Proc tabulate Data=Have;
class year gender question_1;
table gender, year*question_1;
run;

Where do I have to state the rowpctn to get the desired result?


Solution

  • While waiting for a response, I kept searching the internet for an answer, and I managed to find a solution myself.

    The code is below:

    Proc tabulate Data=Have;
    class year gender question_1;
    table gender*pctn<question_1>, year*question_1;
    run;