BookmarkSubscribeRSS Feed
willy0625
Calcite | Level 5

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.

2 REPLIES 2
art297
Opal | Level 21

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=_:) prefix=n_obs;

  var n_obs;

  id enq_3mts_gb;

  by age_gp notsorted;

run;

proc transpose data=need

   out=temp2 (drop=_:) prefix=mean;

  var mean;

  id enq_3mts_gb;

  by age_gp notsorted;

run;

data want;

  set temp1;

  set temp2;

run;

Ksharp
Super User

You do not give the output.

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

nobs_1 nob_2 mean_1 mean_2 ....

Ksharp

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 628 views
  • 3 likes
  • 3 in conversation