Help using Base SAS procedures

transpoing tables and labelling the column variables

Reply
Contributor
Posts: 27

transpoing tables and labelling the column variables

I have been working with some dataset called test2.

Proc means data=test2;

      var gb_bin;

      class AGE_GP ENQ_3MTS_GB;

      output out=age_3 mean()=;

run;

Analysis Variable : GB_bin

AGE_GP

ENQ_3MTS_GB

N Obs

N

Mean

Std Dev

Minimum

Maximum

18 - 20

0

125

125

0.128

0.335434

0

1

1

10400

10400

0.124808

0.330517

0

1

20 - 22

0

316

316

0.10443

0.306303

0

1

1

10151

10151

0.102552

0.303387

0

1

This is the first few lines of the table generated by the above proc means.

Could anyone please tell me how to transpose this table so that I would obtain a table that looks like 

ENQ_3MTS_GB

0

ENQ_3MTS_GB

1

N obs

Mean

Age_GP

Just to clarify, Age_Gp is a factor with many levels(18-20, 20-22, …) and ENQ_3MTS_GB is a binary variable.

I would like to make sure N obs would show up after I transpose

Many thanks.

PROC Star
Posts: 7,473

transpoing tables and labelling the column variables

Posted in reply to willy0625

There are a number of ways to accomplish what I think you want.  One way might be something like:

data need;

  set have;

  last_age_gp=lag(age_gp);

  if mod(_n_,2) eq 0 then age_gp=last_age_gp;

run;

proc transpose data=need

   out=temp1 (drop=_Smiley Happy prefix=n_obs;

  var n_obs;

  id enq_3mts_gb;

  by age_gp notsorted;

run;

proc transpose data=need

   out=temp2 (drop=_Smiley Happy prefix=mean;

  var mean;

  id enq_3mts_gb;

  by age_gp notsorted;

run;

data want;

  set temp1;

  set temp2;

run;

Super User
Posts: 10,028

transpoing tables and labelling the column variables

Posted in reply to willy0625

You do not give the output.

Also want 1 2 for nobs and mean ...?

nobs_1 nob_2 mean_1 mean_2 ....

Ksharp

Ask a Question
Discussion stats
  • 2 replies
  • 114 views
  • 3 likes
  • 3 in conversation