BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gabon
Calcite | Level 5

Hello,

I'm trying to compute column percentages and total percentages for my data. The problem is, proc freq gets correct results, but not the desired table layout, with proc tabulate I can get desired layout but slightly different column percentages results, how is this possible? Can someone advise me how to adjust my proc tabulate to get the same column percentages and total percentages as my proc freq?

My data step is the same for both procedures:

data work.subset1;

   set library.database

   where HS01 between 1 and 5;

   keep pid AGE sex WGT HS01;

run;

My proc freq step and output:

proc freq data=work.subset1;

   tables HS01*(sex AGE)/nofreq norow;

   weight WGT;

   format HS01 sbjzdravie. sex pohlavie. AGE vek.;

run;

output7.jpg

My proc tabulate step with the same data step.. and output:

proc tabulate data=work.subset1;

  class HS01 sex AGE;

  table (HS01 all)*f=5.1, (all sex)*(colpctn)*f=5.1 AGE*colpctn*f=5.1;

  weight WGT;

  format HS01 sbjzdravie. sex pohlavie. AGE vek.;

run;

output8.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
gabon
Calcite | Level 5

Thanks! Looked at the documentation, and apparently weight statements for each procedure has slightly different use. In proc freq weight statement it is used for multiplication of observations for counts, whereas in proc tabulate it is used for computation of weighted statistics like mean, variance etc. For the same use as in proc freq, you have to use freq statement in proc tabulate, that will get the same results. Smiley Happy

View solution in original post

3 REPLIES 3
Reeza
Super User

Look at the documentation of the WEIGHT statement for each proc - specifically the defaults.

gabon
Calcite | Level 5

Thanks! Looked at the documentation, and apparently weight statements for each procedure has slightly different use. In proc freq weight statement it is used for multiplication of observations for counts, whereas in proc tabulate it is used for computation of weighted statistics like mean, variance etc. For the same use as in proc freq, you have to use freq statement in proc tabulate, that will get the same results. Smiley Happy

Maggie
Calcite | Level 5

Hi Gabon,

 

Could you please show how you specified FREQ freq statement in proc tabulate? I am stuggling with exact same problem here. My proc tabulate reqult is diff from that of proc freq.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 4801 views
  • 4 likes
  • 3 in conversation