Help using Base SAS procedures

SUM by GROUPS

Reply
Occasional Contributor
Posts: 14

SUM by GROUPS

Hello everyone,

I am beginner in SAS

I have this table

SNAPSHOTCOUNTSEGMENTGROUPdefGRADE
2014014472PRK_LNPL001
2014018691PRK_LNPL002
2014018289PRK_LNPL003
2014012209PRK_LNPL004
2014011450PRK_LNPL005
2014011333PRK_LNPL006
201401364PRK_LNPL007
201401133PRK_LNPL008
2014014PRK_LNPL011
20140122PRK_LNPL012
20140181PRK_LNPL013
20140161PRK_LNPL014
20140167PRK_LNPL015
201401161PRK_LNPL016
201401122PRK_LNPL017
201401130PRK_LNPL018
20140111642PRK_LNPL101
20140119361PRK_LNPL102
20140115284PRK_LNPL103
2014013463PRK_LNPL104
2014012056PRK_LNPL105
2014011895PRK_LNPL106
201401490PRK_LNPL107
201401153PRK_LNPL108
2014019PRK_LNPL111
20140159PRK_LNPL112
201401141PRK_LNPL113
20140198PRK_LNPL114
201401114PRK_LNPL115
201401218PRK_LNPL116
201401189PRK_LNPL117
201401180PRK_LNPL118

I want this table

SNAPSHOTCOUNTSEGMENTGROUPdefGRADESUMDR
2014014472PRK_LNPL0014476 
2014018691PRK_LNPL0028713 
2014018289PRK_LNPL0038370 
2014012209PRK_LNPL0042270 
2014011450PRK_LNPL0051517 
2014011333PRK_LNPL0061494 
201401364PRK_LNPL007486 
201401133PRK_LNPL008263 
2014014PRK_LNPL011 0,089%
20140122PRK_LNPL012 0,252%
20140181PRK_LNPL013 0,968%
20140161PRK_LNPL014 2,687%
20140167PRK_LNPL015 4,417%
201401161PRK_LNPL016 10,776%
201401122PRK_LNPL017 25,103%
201401130PRK_LNPL018 49,430%
20140111642PRK_LNPL10111651 
20140119361PRK_LNPL10219420 
20140115284PRK_LNPL10315425 
2014013463PRK_LNPL1043561 
2014012056PRK_LNPL1052170 
2014011895PRK_LNPL1062113 
201401490PRK_LNPL107679 
201401153PRK_LNPL108333 
2014019PRK_LNPL111 0,077%
20140159PRK_LNPL112 0,304%
201401141PRK_LNPL113 0,914%
20140198PRK_LNPL114 2,752%
201401114PRK_LNPL115 5,253%
201401218PRK_LNPL116 10,317%
201401189PRK_LNPL117 27,835%
201401180PRK_LNPL118 54,054%

In column SUM i need to sum values in column COUNT for each grade and group seperatedly example 4476=4472+4.

In column DR i need to divide value from column COUNT and SUM for each grade and group seperatedly and only there where is in column DEF value=1. example 0,089%=4/4476.

Is here anybody who can solve my problem?

Super User
Posts: 6,936

Re: SUM by GROUPS

Use proc summary with class group grade;

Then remerge the results with your dataset, and set variables according to def.

If you want fitting code, please post your dataset in a data step so we can fit the code to the data.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 1 reply
  • 161 views
  • 0 likes
  • 2 in conversation