/*i have the following dataset.*/
data score;
input marks ;
datalines;
10
20
30
40
50
60
70
80
90
100
;
run;
Now i should get the result as sum of 1 to 5 i.e(10+20+30+40+50)=150
and 2 to 6 i.e(20+30+40+50+60)=200
and 3 to 7 i.e(30+40+50+60+70)=250 and so on.
how to get it.
thanks in advance
Answers were Sorted based on User's Feedback
Answer / naveen kumar
proc transpose data=score out=score2 prefix= mark;
var marks;
quit;
data score2;
set score2;
sum1=sum(mark1,mark2,mark3,mark4,mark5);
sum2=sum(mark2,mark3,mark4,mark5,mark6);
sum3=sum(mark3,mark4,mark5,mark6,mark7);
sum4=sum(mark4,mark5,mark6,mark7,mark8);
sum5=sum(mark5,mark6,mark7,mark8,mark9);
sum6=sum(mark6,mark7,mark8,mark9,mark10);
run;
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / tandon
PROC TRANSPOSE DATA=SCORE OUT=SCORE2 NAME=SUBJECT PREFIX=MARKS;
VAR MARKS;
RUN;
PROC PRINT DATA=SCORE2;
RUN;
DATA SUM;
SET SCORE2;
A=SUM(OF MARKS1 - MARKS5);
B=SUM(OF MARKS2 - MARKS6);
C=SUM(OF MARKS3 - MARKS7);
D=SUM(OF MARKS4 - MARKS8);
E=SUM(OF MARKS5 - MARKS10);
RUN;
PROC PRINT DATA=SUM HEADING=H;
OPTIONS LS=150;
RUN;
| Is This Answer Correct ? | 1 Yes | 2 No |
hi guys ...i have one query... data abc; input s w k g o t a m; cards; 1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 9 ; run; i want the output to be the sorted order(only variables).observations should not be changed..
what are some good sas programming practices for processing very large data sets? : Sas programming
How do dates work in SAS data?
If i doest required Cumilative frequency in my table, generated by using PROC FREQ what i had to do?
what is SAS OPTIMIZATION?
Why Info School? BUILD YOUR CAREER WITH RIGHT GUIDANCE AND SUPPORT SAS Training in Data Management at InfoSchool Bangalore
how do the in= variables improve the capability of a merge? : Sas programming
what is sas data set?
what is lifetest
Name validation tools used in SAS
I use NOCUM/NOPERCENT option in the tables statement like this Proc freq data = deepak; tables x y /nocum nopercent; run; Here I get nopercent and nocum in the output only for variables x and y. How do i do it for all variables? Deepak
What do the sas log messages “numeric values have been converted to character” mean? What are the implications?