DATA Step, Macro, Functions and more

SAS query

Accepted Solution Solved
Reply
Contributor scb
Contributor
Posts: 50
Accepted Solution

SAS query

pct and totalpct are in format percent

 

I have the following dataset

 

id        report    pct

434     ABC      30

145     CBD      29

156     1ABN     31

171     gdhd      10

 

I would like to have the cumulative total for pct as below

 

id        report    pct   totalpct

434     ABC      30    30

145     CBD      29    59

156     1ABN     31    90

171     gdhd      10    100

 

Can anyone help? thank you.

 


Accepted Solutions
Solution
‎04-09-2016 05:58 PM
Respected Advisor
Posts: 4,649

Re: SAS query

data want;

set have;

totalpct + pct;

run;

PG

View solution in original post


All Replies
Solution
‎04-09-2016 05:58 PM
Respected Advisor
Posts: 4,649

Re: SAS query

data want;

set have;

totalpct + pct;

run;

PG
Super User
Posts: 5,256

Re: SAS query

If you have access to the original data, PROC FREQ has cumulative pct AOTB.
Otherwise define totalpct with a RETAIN statement in a data step, and just add with pct.
Data never sleeps
New Contributor
Posts: 2

Re: SAS query

data have;
input id report $ pct ;
tpct+pct;
datalines;
434 ABC 30
145 CBD 29
156 1ABN 31
171 gdhd 10
;
run;

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 211 views
  • 0 likes
  • 4 in conversation