Data visualization with SAS programming

Tabulate Weight

Accepted Solution Solved
Reply
Super Contributor
Posts: 494
Accepted Solution

Tabulate Weight

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

https://books.google.com/books?id=6lpACQAAQBAJ&pg=PT230&lpg=PT230&dq=tabulate+sumwgt&source=bl&ots=m...

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;

     /*var gender / weight=admissions;*/

  class academic_period_desc gender;

  table academic_period_desc, gender*rowpctn gender*colpctn;

run;


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

Re: Tabulate Weight

Try the FREQ option instead of Weight.

View solution in original post


All Replies
Super User
Posts: 19,194

Re: Tabulate Weight

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

proc tabulate data=sashelp.class out=barGraphDataTEST;

     /*var gender / weight=admissions;*/

  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;

     /*var gender / weight=admissions;*/

  class age gender;

  table age, gender*rowpctn gender*colpctn;

run;

Super Contributor
Posts: 494

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: 19,194

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.

Super Contributor
Posts: 494

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.

Super Contributor
Posts: 494

Re: Tabulate Weight

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

gender.png

Super Contributor
Posts: 494

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;

  var admissions;

  class academic_period_desc gender;

  table academic_period_desc, gender*(admissions*rowpctn) gender*(admissions*colpctn);

run;

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

proc tabulate data=enrollment out=barGraphDataTEST;

  weight admissions;

  class academic_period_desc gender;

  table academic_period_desc, (gender*admissions)*rowpctn (gender*admissions)*colpctn;

run;

Super User
Posts: 19,194

Re: Tabulate Weight

Can you post sample input data?

Super Contributor
Posts: 494

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: 19,194

Re: Tabulate Weight

Try the FREQ option instead of Weight.

Super Contributor
Posts: 494

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;

  freq admissions;

  class year gender;

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

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 660 views
  • 0 likes
  • 2 in conversation