Help using Base SAS procedures

Summing a column in a very large dataset.

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

Summing a column in a very large dataset.

Good morning.

I have a dataset that contains about 20 variables and roughly a million observations.

One of the variables is Transaction_Amount

All I want to do is create a total value for that variable, I have tried to use proc print however the procedures takes ages and completely halts my system.

Can someone please advise me of a really simple and not resource heavy way to do this.

Thank you in advance.

Stret


Accepted Solutions
Solution
‎06-26-2014 04:11 AM
Super User
Posts: 6,927

Re: Summing a column in a very large dataset.

Several ways.

proc sql;

select sum(Transaction_Amount) from want;

quit;

or

proc summary data=want sum print;

var Transaction_Amount;

run;

or

data _null_;

set want end=atlast;

retain sum_ta 0;

sum_ta + Transaction_Amount;

if atlast then put sum_ta=;

run;

The last one shows the sum in the log.

Proc print will output all the data lines, which will be too much for, say, Enterprise Guide to display. And takes so long because it transfers all the data across the network.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎06-26-2014 04:11 AM
Super User
Posts: 6,927

Re: Summing a column in a very large dataset.

Several ways.

proc sql;

select sum(Transaction_Amount) from want;

quit;

or

proc summary data=want sum print;

var Transaction_Amount;

run;

or

data _null_;

set want end=atlast;

retain sum_ta 0;

sum_ta + Transaction_Amount;

if atlast then put sum_ta=;

run;

The last one shows the sum in the log.

Proc print will output all the data lines, which will be too much for, say, Enterprise Guide to display. And takes so long because it transfers all the data across the network.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 49

Re: Summing a column in a very large dataset.

This is great.

Thank you for this:smileycool:

Stret

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 215 views
  • 2 likes
  • 2 in conversation