data test ;
input x;
datalines;
1
2
3
4
5
6
7
;
run;
Q) how can I get total of x in single observation ?
Any of the steps 2 through 4 below will work:
data test ;
input x ;
cards ;
1
2
3
4
5
6
7
;
run ;
data need (drop = x) ;
set test end = z ;
sum_x + x ;
if z ;
run ;
proc sql ;
create table need as select sum (x) as sum_x from test ;
quit ;
proc means data = test noprint ;
var x ;
output out = need (drop = _:) sum = sum_x ;
run ;
Kind regards
Paul D.
data test ;
input x;
datalines;
1
2
3
4
5
6
7
;
run;
Q) how can I get total of x in single observation ?
Any of the steps 2 through 4 below will work:
data test ;
input x ;
cards ;
1
2
3
4
5
6
7
;
run ;
data need (drop = x) ;
set test end = z ;
sum_x + x ;
if z ;
run ;
proc sql ;
create table need as select sum (x) as sum_x from test ;
quit ;
proc means data = test noprint ;
var x ;
output out = need (drop = _:) sum = sum_x ;
run ;
Kind regards
Paul D.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.