The DATA statement is what starts your DATA step program ... this is the program where you are reading values for NUM1 into a SAS dataset.
You can't calculate the SUM of the NUM1 variable in a DATA statement. However, within a DATA step program, you can create a new variable to hold the total of the sum of the NUM1 values on every observation.
However, I wonder why you want to calculate the total of NUM1 in a DATA step program. Do you need a REPORT that shows the summary of all the NUM1 values??? You could do this with PROC PRINT, without creating any new variables in the dataset. (Or you could use any number of other procedures.)
If you do need to calculate the sum of NUM1 in the DATA step program, then you would need to create a new variable with an assignment statement. Possibly you would use a RETAIN statement so that you could retain the value of your total-holding variable from observation to observation. Then you have to decide how you want to deal with the total at the end of the input file -- what do you envision seeing in the output dataset??? You don't have any other identifying variables (like a category variable or name, etc), so how would you distinguish the total of 2100 from the "regular" observation lines?? This is what leads me to wonder whether you really just want a report with a summary line versus calculating the total of NUM1 in a DATA step program.
Thank you for your solution,
this is asked me in the interview, i defend the answer as you explain me in the above, but the interviewer except from me as follows
by using DATA Statement,
so that i posted this question to get the answer, is there any way to find
I am giving BASE SAS certification, If you have information, could you please let me know what are changes happen in SAS 9.2, what i need to cover in SAS 9.2 before taking certification, if you have pattern and sample questions on BASE SAS please post me.