I'm really new to SAS and would appreciate some help..
Like Fareeza said, such stats are easily calculated using one of the SAS procs.
Your problem clearly looks like a homework assignment and, if the solution code is your own, your calculation formula is wrong. You would definitely have to capture and use N somewhere in your formula.
You can easily include some minor proc sql code to capture and store the desired numbers in macro variables. And you can print them in your log so that you follow your prof's preferred approach. e.g.:
proc sql;
select count(*),sum(x),sum(y),sum(x**2),sum(y**2)
into :n,:xsum,:ysum,:x2sum,:y2sum
from Question1
;
quit;
%put &n;
%put &xsum;
%put &ysum;
%put &x2sum;
%put &y2sum;
Conversely, Using the proc print approach, you could do something like the following to get the desired N:
proc print data=Question1 n='# of cases:' noobs;
sum x y x2 y2;/*get sums of variables from this table to use in your analysis-I like this way best since I can see the actual calculations*/
run;
Hope this is what you are expecting
data XY;
input x y;
ord=1;
datalines;
18 23
13 20
18 18
15 16
10 14
12 11
8 10
4 7
7 6
3 4
;
run;
proc sort data=xy;
by ord;
run;
data want;
set xy;
by ord;
if first.ord then do;
sumx=x;
sumy=y;
end;
else do;
sumx+x;
sumy+y;
end;
run;
Thanks,
Jag
Given your example, what do you want the result to look like?
Like Fareeza said, such stats are easily calculated using one of the SAS procs.
Your problem clearly looks like a homework assignment and, if the solution code is your own, your calculation formula is wrong. You would definitely have to capture and use N somewhere in your formula.
You can easily include some minor proc sql code to capture and store the desired numbers in macro variables. And you can print them in your log so that you follow your prof's preferred approach. e.g.:
proc sql;
select count(*),sum(x),sum(y),sum(x**2),sum(y**2)
into :n,:xsum,:ysum,:x2sum,:y2sum
from Question1
;
quit;
%put &n;
%put &xsum;
%put &ysum;
%put &x2sum;
%put &y2sum;
Conversely, Using the proc print approach, you could do something like the following to get the desired N:
proc print data=Question1 n='# of cases:' noobs;
sum x y x2 y2;/*get sums of variables from this table to use in your analysis-I like this way best since I can see the actual calculations*/
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.