DATA Step, Macro, Functions and more

combining sets of observations by name

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 110
Accepted Solution

combining sets of observations by name

Hi All, I have the following dataset; What I am trying to doe is to combine the total frequency by name. Some of the names are composed of two words with a space in the middle. 

 

 

med_code freq  name 
0001 50   ar
222  3     ar 
444 3     ar 
555  2   al as
666 1   al as 



Here is the output I am looking to get

ar      56
al as  3

 


Accepted Solutions
Solution
‎04-06-2016 10:33 AM
Super User
Posts: 6,938

Re: combining sets of observations by name

proc sql;
create table want as
select name,sum(freq)
from have
group by name;
quit;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎04-06-2016 10:33 AM
Super User
Posts: 6,938

Re: combining sets of observations by name

proc sql;
create table want as
select name,sum(freq)
from have
group by name;
quit;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 110

Re: combining sets of observations by name

Thank you! 

Super User
Posts: 5,256

Re: combining sets of observations by name

Simple SQL w sum() and group by.
Data never sleeps
Frequent Contributor
Posts: 110

Re: combining sets of observations by name

Thank you!
☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 237 views
  • 4 likes
  • 3 in conversation