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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 5 replies
  • 1065 views
  • 1 like
  • 6 in conversation