DATA Step, Macro, Functions and more

Using of GROUP

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Using of GROUP

Hi

 

I am new to SAS, Please hlp me in resoving a sample business problem.

 

I have sample records below .

 

SAS-dataset.png

 

 

I need to find the total usage of each customer for Home and roaming circle.

 

Thanks 

 


Accepted Solutions
Solution
‎04-27-2017 06:01 AM
PROC Star
Posts: 552

Re: Using of GROUP

Gotta say, not very clear from your subject line "Using of Group".

 

Here is a datastep solution, again, not tested.

 

proc sort data = have;
	by circle;
run;

data want;
	set have;
	by circle;
	sum = sum + minutes;
	if last.circle then output;
	retain sum 0;
run;

View solution in original post


All Replies
Occasional Contributor
Posts: 19

Re: Using of GROUP

Sample Dataset is attached. 


Screen Shot 2017-04-27 at 12.54.15 PM.png
PROC Star
Posts: 552

Re: Using of GROUP

[ Edited ]

Please post your data in the form of a datastep, mush easier to help that way

 

This is not tested but you are probably looking for something like this

 

proc sql;
	create table want as
	select circle
	      ,sum(minutes)
	from have
	group by circle;
quit;
Occasional Contributor
Posts: 19

Re: Using of GROUP

I dont want to use proc sql.

Super User
Super User
Posts: 7,403

Re: Using of GROUP

Use proc means with a by group then.  

http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n0k7qr5c2ah3stn10g1lr...

 

Also, try not to limit yourself with what tools you can and can't use, they are all useful.

Occasional Contributor
Posts: 19

Re: Using of GROUP

I am new and learning SAS, i just want to do in that way nothing else.

 

Super User
Super User
Posts: 7,403

Re: Using of GROUP

In what way, please be specific.  You have said GROUP which indicates SQL, then you say you don't want to use that.  So the next option is using a procedure designed to create means output - proc means, however this also doesn't seem to fit what you want.  So please be clear in your posts exactly what it is you want so we don't go through these loops of trying to figure it out.  

Super User
Posts: 6,941

Re: Using of GROUP


vishyy wrote:

I dont want to use proc sql.


Why?

See Maxim 14.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 19

Re: Using of GROUP

I am new and learning SAS, i just want to do in that way nothing else.

Thanks for nudging. 

Super User
Posts: 6,941

Re: Using of GROUP

And you still have not provided example data in a usable form.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎04-27-2017 06:01 AM
PROC Star
Posts: 552

Re: Using of GROUP

Gotta say, not very clear from your subject line "Using of Group".

 

Here is a datastep solution, again, not tested.

 

proc sort data = have;
	by circle;
run;

data want;
	set have;
	by circle;
	sum = sum + minutes;
	if last.circle then output;
	retain sum 0;
run;
Super User
Posts: 6,941

Re: Using of GROUP

A macro for semi-automatic conversion of a dataset to a data step can be found here.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is SOLVED.

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

Discussion stats
  • 11 replies
  • 151 views
  • 4 likes
  • 4 in conversation