BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jc3992
Pyrite | Level 9

Hello everyone,

 

The code provided by our instructor was as below:

 

PROC TABULATE DATA = boats;
   CLASS Port Locomotion Type;
   TABLE Port, Locomotion*Type;
   TITLE 'Number of Boats by Port, Locomotion, and Type';
RUN;

Under "Table" command,

The "," (comma) means "crossing", and the "*"( the asterisk) means "nesting"

I am a bit confused about these two concepts.

I know "crossing" is like row and column,

but what about "nesting"?

Is there anybody would like to elaborate a little bit for me?

 

Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Nesting means to for each level of Locomotion each level of type will have a column or row of output (depending on which dimension the nested expression is in.

 

If you have a data set run the code.

Or look at this with a data set you should have:

proc tabulate data=sashelp.class;
   class sex age;
   var height weight;
   tables sex*age,
          height*max weight*mean;
run;

which generates rows of data having age values within sex values. Note that M has a row for age 16 but F doesn't as there aren't any values of age=16 for females in that data set.

 

A secondary form of nesting involves the STATISTICS choices. The example above shows one statistic for height and weight. Using parentheses we can specify multiple statistics "nested" for an analysis variable:

proc tabulate data=sashelp.class;
   class sex age;
   var height weight;
   tables sex*age,
          (height weight) * (mean max);
run;

Requests mean and maximum values for both height and weight.

 

View solution in original post

2 REPLIES 2
ballardw
Super User

Nesting means to for each level of Locomotion each level of type will have a column or row of output (depending on which dimension the nested expression is in.

 

If you have a data set run the code.

Or look at this with a data set you should have:

proc tabulate data=sashelp.class;
   class sex age;
   var height weight;
   tables sex*age,
          height*max weight*mean;
run;

which generates rows of data having age values within sex values. Note that M has a row for age 16 but F doesn't as there aren't any values of age=16 for females in that data set.

 

A secondary form of nesting involves the STATISTICS choices. The example above shows one statistic for height and weight. Using parentheses we can specify multiple statistics "nested" for an analysis variable:

proc tabulate data=sashelp.class;
   class sex age;
   var height weight;
   tables sex*age,
          (height weight) * (mean max);
run;

Requests mean and maximum values for both height and weight.

 

jc3992
Pyrite | Level 9

Thank you!

Understand!

 

Thanks for the example!

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →
Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 2 replies
  • 3466 views
  • 1 like
  • 2 in conversation