Help using Base SAS procedures

Coding Question

Reply
Occasional Contributor
Posts: 5

Coding Question

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,

Super User
Super User
Posts: 7,400

Re: Coding Question

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.

Community Manager
Posts: 2,758

Re: Coding Question

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

PROC Star
Posts: 7,361

Re: Coding Question

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;

Respected Advisor
Posts: 4,644

Re: Coding Question

... 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
Super User
Posts: 9,676

Re: Coding Question

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

proc glm

proc anova

Xia

Ask a Question
Discussion stats
  • 5 replies
  • 233 views
  • 1 like
  • 6 in conversation