SAS create a table with a loop

Reply
New User
Posts: 1

SAS create a table with a loop

Dear all, 

 

I just started to learn and use SAS… I’am currently facing a problem and hope someone would be able to help me. 

 

I have a database of the following form : 

 

Capture d’écran 2015-09-14 à 23.33.18.png

 

What I would like is to create a table that will contains the number of observation per group. So something like : 

 

Capture d’écran 2015-09-14 à 23.41.00.png

 

I am trying to work with a loop that will complete progressively the table but after many trials i am unable to do so… Does someone has an idea ? 

 

Thank you very much

PROC Star
Posts: 7,468

Re: SAS create a table with a loop

Proc summary is nice to use for such situations. e.g.,

 

proc summary data=have nway;
  class model;
  var option1-option3;
  output out=want (drop=_Smiley Happy sum=;
run;

 

Frequent Contributor
Posts: 144

Re: SAS create a table with a loop

[ Edited ]

An other way to do the same, is create the summary with SQL.

 

PROC SQL;

  create table summary as(

    select model, sum(option1) as option1, sum(option2) as option2, sum(option3) as option3

    from have

    group by model  /*This option make the sum by model*/

  );

 

QUIT;

Ask a Question
Discussion stats
  • 2 replies
  • 237 views
  • 1 like
  • 3 in conversation