🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 04-09-2016 05:37 PM
(1142 views)
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.
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
totalpct + pct;
run;
PG
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Otherwise define totalpct with a RETAIN statement in a data step, and just add with pct.
Data never sleeps
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data have;
input id report $ pct ;
tpct+pct;
datalines;
434 ABC 30
145 CBD 29
156 1ABN 31
171 gdhd 10
;
run;