BookmarkSubscribeRSS Feed
Wendy13
Calcite | Level 5

I am struggling with coding with following questions:

I need to find difference between male and female from dataset and find significance between male and female.

First, should I subset or split dataset?

There are variables for each male and female so I think I need to create a new variable with add number of variables.

What is a code to get significance between male and female?

Please help me,

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

You shouldn't need to split your dataset, SAS does by group processing so just use gender as a by or class variable.  E.g.

proc sort data=sashelp.classfit out=tmp;

  by sex;

run;

proc means data=tmp noprint;

     var age;

     by sex;

     output out=myres n=n mean=mean stddev=stddev min=min max=max;

run;

This will give you means results by sex from the sashelp table.

As for significance, not sure, your best off posting that question in Statistical Procedures sub forum.

ChrisHemedinger
Community Manager

is correct -- no need to split the data.  However, one improvement on this answer: you don't need to use BY groups or SORT the data first with PROC MEANS.  You can use the CLASS statement instead:

proc means data=sashelp.classfit noprint;
    
var age;
     class sex;
     output out=myres n=n mean=mean stddev=stddev min=min max=max;
run;

Result:

classout.png

The first record is the stats for ALL observations, and the next two records are for F and M, respectively.

Chris

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
art297
Opal | Level 21

If you only need to analyze one variable, you could get everything you want by running proc ttest. e.g.:

proc ttest data=sashelp.class;

   class sex;

   var weight;

run;

PGStats
Opal | Level 21

... IF (big if) your data has a normal distribution. Otherwise, or instead, since there is not is not much power lost, go for non-parametric analyses :

proc npar1way data=sashelp.class Wilcoxon;

   class sex;

   var weight;

   exact Wilcoxon;

run;

PG

PG
Ksharp
Super User

IF you have more than two levels, Don't forget to use variance analysis .Smiley Wink

proc glm

proc anova

Xia

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1431 views
  • 1 like
  • 6 in conversation