Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8238607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:52:19+00:00 2026-06-07T19:52:19+00:00

if you use proc summary with class-clause, it will sort your observations in order

  • 0

if you use proc summary with class-clause, it will sort your observations in order of this class-clause.

proc summary data=One;
   by var_1;
   class var_2 var_3 var_4;
   output out = Two(drop= _freq_ _type_);
run;

1) am i right?

2) what happens, if i don’t specify all fields?

proc summary data = Three(keep= var_1 var_2 var_ 3 var_4 var_5 var_6);
   by var_1;
   class var_2 var_3;
   output out = Four(drop= _freq_ _type_ );
run;

3) which proc faster: proc summary or proc sort?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:52:20+00:00Added an answer on June 7, 2026 at 7:52 pm

    A few things to note here.

    • In order to preserve the same number of rows, you need to specify the nway option in the proc summary statement. Without it you will get every 1, 2 and 3 combination of class variables.
    • I’m not sure why you have the BY statement (this obviously indicates the data is already sorted by that variable). You could just as easily include var_1 in the CLASS statement.
    • Proc Summary will sort the output in the order of the BY variables first, followed by the CLASS variables in the order they are specified.
    • This logic applies irrespective of which variables are kept.
    • Proc Sort should work faster in this simple instance, as Proc Summary will carry out further calculations that aren’t required.
    • I sometimes use Proc Summary to sort and dedupe data in one step (using the maxid function), e.g. where I have multiple ID’s per day and I want to only take the latest one. This saves having to sort the data and then extract the last record per day per ID.

    Hope this helps.

    Here is an example of my last point. Using _all_ asks to return all variables in the dataset, this does create a warning in the log for the variables previously listed in the CLASS statement, but it can be safely ignored. It’s basically me being lazy in not wanting to specify the remaining variables separately for wide datasets.

    data have;
    input unique_id custno log_dt :datetime15.;
    format log_dt datetime15.;
    cards;
    1 123 01jul2012:13:23
    2 265 01jul2012:13:56
    3 342 01jul2012:15:02
    4 123 01jul2012:17:12
    5 342 01jul2012:18:33
    6 265 02jul2012:08:41
    7 123 02jul2012:10:14
    8 265 02jul2012:11:05
    ;
    run;
    
    proc summary data=have nway;
    class custno log_dt;
    format log_dt dtdate9.;
    output out=want (drop=_:) maxid(log_dt(_all_))=;
    run;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to man 5 proc , one can use the /proc filesystem to access
I have this simple perl daemon: #!/usr/bin/perl use strict; use warnings; use Proc::Daemon; Proc::Daemon::Init;
We use the /proc and /sys file systems in Linux to discover various types
use Rack::Static, :urls => ['/stylesheets', '/images'], :root => 'public' run proc { |env| [200,
I am trying to understand my embedded Linux application's memory use. The /proc/pid/maps utility/file
Can you have code that looks like this? def methodname () { proc =
Is it safe to use lseek(fd,0) and then read(fd,buf) for /proc/stat file instead of
I'd like to use . to call sql script from inside a stored proc
I want to use fw_printenv for get U-boot's env. $cat /proc/mtd mtd0: 00060000 00004000
Here is a cut from my daemon code: package somepackage; use Proc::Daemon; use Time::HiRes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.