DATA Step, Macro, Functions and more

combining sets of observations by name

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 128
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: 7,866

Re: combining sets of observations by name

Posted in reply to lillymaginta
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: 7,866

Re: combining sets of observations by name

Posted in reply to lillymaginta
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: 128

Re: combining sets of observations by name

Posted in reply to KurtBremser

Thank you! 

Super User
Posts: 5,441

Re: combining sets of observations by name

Posted in reply to lillymaginta
Simple SQL w sum() and group by.
Data never sleeps
Frequent Contributor
Posts: 128

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
  • 239 views
  • 4 likes
  • 3 in conversation