Solved
Valued Guide
Posts: 531

# Tabulate Weight

I'm following the example in Weight the Results II in the book:

and I’m running into the error

ERROR: Variable GENDER in list does not match type prescribed for this list.

when I uncomment the comment below.  Does the line not work in SAS 9.2?  Am I missing something simple?

I’m trying to multiply gender by the number of admissions.

proc tabulate data=enrollment out=barGraphDataTEST;

run;

Accepted Solutions
Solution
‎08-18-2015 10:48 AM
Super User
Posts: 21,546

## Re: Tabulate Weight

Try the FREQ option instead of Weight.

All Replies
Super User
Posts: 21,546

## Re: Tabulate Weight

It works as both char and numeric for me in SAS9.3

proc tabulate data=sashelp.class out=barGraphDataTEST;

class age sex;

table age, sex*rowpctn sex*colpctn;

run;

data class;

set sashelp.class;

gender=ifn(sex='F', 1, 0);

run;

proc tabulate data=class out=barGraphDataTEST;

class age gender;

table age, gender*rowpctn gender*colpctn;

run;

Valued Guide
Posts: 531

## Re: Tabulate Weight

In 9.2 this breaks

proc tabulate data=sashelp.class out=barGraphDataTEST;

var sex / weight=age;

class age;

table age, sex*rowpctn sex*colpctn;

run;

Super User
Posts: 21,546

## Re: Tabulate Weight

It does in 9.3 as well.

Sex should be a class variable as it's a grouping variable not an analysis variable.

Valued Guide
Posts: 531

## Re: Tabulate Weight

How can I multiply a grouping variable by a weight column?  E.g. Sex by age and still use the rowpctn with it?  The idea is if there are 15 instances of gender and the column age = 100.  The value should be 1500.

Valued Guide
Posts: 531

## Re: Tabulate Weight

What I am trying to create is like this multiplied by the column admissions.

Valued Guide
Posts: 531

## Re: Tabulate Weight

This produces the same structure but oddly does not multiply by admissions.  It simply adds the grouping admissions above gender.

proc tabulate data=enrollment out=barGraphDataTEST;

run;

This produces the same thing.  It doesn't actually weight.

proc tabulate data=enrollment out=barGraphDataTEST;

run;

Super User
Posts: 21,546

## Re: Tabulate Weight

Can you post sample input data?

Valued Guide
Posts: 531

## Re: Tabulate Weight

data genderData;

input gender \$ 1-12 year admissions;

datalines;

Not Reported 2010 3

Not Reported 2011 5

Not Reported 2012 7

Not Reported 2013 6

Not Reported 2014 4

Male         2010 5

Male         2011 1

Male         2012 1

Male         2013 3

Male         2014 4

Female       2010 2

Female       2011 1

Female       2012 1

Female       2013 2

Female       2014 1

;

Solution
‎08-18-2015 10:48 AM
Super User
Posts: 21,546

## Re: Tabulate Weight

Try the FREQ option instead of Weight.

Valued Guide
Posts: 531

## Re: Tabulate Weight

thanks

This worked.

data genderData;

input gender \$ 1-12 year admissions;

datalines;

Not Reported 2010 3

Not Reported 2011 5

Not Reported 2012 7

Not Reported 2013 6

Not Reported 2014 4

Male         2010 5

Male         2011 1

Male         2012 1

Male         2013 3

Male         2014 4

Female       2010 2

Female       2011 1

Female       2012 1

Female       2013 2

Female       2014 1

;

proc tabulate data=genderData out=barGraphDataTEST;

class year gender;

table year, (gender)*rowpctn (gender)*colpctn;

run;

🔒 This topic is solved and locked.