ViB
ViB

Reputation: 65

How to create nested rows in SAS?

I am a beginner so my knowledge is lacking. I have a data set consisting of the following columns:

I wish to create a table such that for every 1 person i have three rows called Age, Height, Weight.

I have tried to use Proc Tabulate :

proc tabulate data=new;

   class person;

   var NEWCOLUMN;

   table person,NEWCOLUMN;

run;

However i am getting an error because the new column is not the correct type.

Upvotes: 1

Views: 227

Answers (1)

Richard
Richard

Reputation: 27498

You can pivot the data per person and REPORT or TABULATE the cell values.

Example:

proc transpose data=sashelp.class out=pivoted;
  by name;
  var age height weight;
  where name <= 'C';
run;

ods html file='output.html' style=plateau;

options nodate nonumber nocenter;
title; footnote;

proc report data=pivoted;
  column name _name_ col1;
  define name / ' ' order order=data;
  define _name_ / ' ';
  define col1 / ' ';
run;

proc tabulate data=pivoted;
  class name _name_ / order=data;
  var col1;
  table name*_name_='', col1=''*min='' / nocellmerge;
run;

ods html close;

Output
enter image description here

Upvotes: 2

Related Questions