BookmarkSubscribeRSS Feed
nridwan
Calcite | Level 5

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

2 REPLIES 2
art297
Opal | Level 21

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=_:) sum=;
run;

 

arodriguez
Lapis Lazuli | Level 10

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 543 views
  • 1 like
  • 3 in conversation