Help using Base SAS procedures

How to calculate Syy, Sxx, Sxy, x^2, etc?

Reply
New Contributor
Posts: 4

How to calculate Syy, Sxx, Sxy, x^2, etc?

I'm incredibly new at SAS. My professor isn't very clear to say the least. 

 

Is there way to calculate all of the inputs needed for linear regression hand calculations? Like x^2, y^2, Sxy, Syy, etc? I Googled it and it didn't come up with anything. I'm using SAS University Edition. This is my code for what I'm doing. But it doesn't give everything I'd need for hand calculations. 

Data 3Correllation;

Input y x;
Lny=log(y);
Lnx=log(x);
Cards;

29186 0.414 
29266 0.383
26215 0.399 
30162 0.402
38867 0.442
37831 0.422 
44576 0.466 
46097 0.500
59698 0.514
67705 0.530
66088 0.569
78486 0.558
89869 0.577
77369 0.572
67095 0.548
85156 0.581
69571 0.557
84160 0.550
73466 0.531
78610 0.550
67657 0.556
74017 0.523
87291 0.602
86836 0.569
82540 0.544
81699 0.557
82096 0.530
75657 0.547
80490 0.585
;

Proc reg; Model lny=lnx;

Proc Print;
run;

 

I know this is a ridiculous question and for that I apologize...

 

 

Super User
Posts: 19,167

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

I think the intention is likely for you to do this manually using a data step. 

 

However, I think you can also get some of the stats you want from here, but if you have to do the data step you may as well do them all manually. Personally, I do think it's a good exercise to understand the data and know how it flows though it's probably annoying since the computer can do it all. 

http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p0v0y1on1hbxukn0zqgsp...

 

If you're having trouble with the data step, post what you've tried and we can help out - however, I have a personal policy of not coding answers for homework. Debugging, corrections and pointing you in the direction are all fine to me though Smiley Happy

 

Good Luck.

 


taggerung wrote:

I'm incredibly new at SAS. My professor isn't very clear to say the least. 

 

Is there way to calculate all of the inputs needed for linear regression hand calculations? Like x^2, y^2, Sxy, Syy, etc? I Googled it and it didn't come up with anything. I'm using SAS University Edition. This is my code for what I'm doing. But it doesn't give everything I'd need for hand calculations. 

Data 3Correllation;

Input y x;
Lny=log(y);
Lnx=log(x);
Cards;

29186 0.414 
29266 0.383
26215 0.399 
30162 0.402
38867 0.442
37831 0.422 
44576 0.466 
46097 0.500
59698 0.514
67705 0.530
66088 0.569
78486 0.558
89869 0.577
77369 0.572
67095 0.548
85156 0.581
69571 0.557
84160 0.550
73466 0.531
78610 0.550
67657 0.556
74017 0.523
87291 0.602
86836 0.569
82540 0.544
81699 0.557
82096 0.530
75657 0.547
80490 0.585
;

Proc reg; Model lny=lnx;

Proc Print;
run;

 

I know this is a ridiculous question and for that I apologize...

 

 


 

 

New Contributor
Posts: 4

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

So I'd do a data step with CSS for (xi-xbar)^2?

 

I'm just an undergraduate. My professor tells us what to write,  but doesn't explain anything. Like he literally just wrote the code and said do it. 

 

Is Adjusted R Squared the correlation coefficient r?

Super User
Posts: 19,167

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

I'm assuming you have a text book. It should have the terms and definitions. If not, the first SAS Statistics course is free online but I'm not sure it goes into the detail here.

 

This is long, but it's a full walk through of a linear regression in SAS:

https://stats.idre.ucla.edu/sas/webbooks/reg/chapter1/regressionwith-saschapter-1-simple-and-multipl...

 

PS - the best thing you learn in University is how to find the answers to questions, to the point I consider it a valuable interview question Smiley Happy

New Contributor
Posts: 4

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

No, he didn't require a SAS textbook. Only a textbook on probability. Trust me, I'm trying to find answers. I've been trying since yesterday. I just don't know how. I don't even know how to write a proper SAS procedure because I don't have the resources. No book, no professor that's any help, and since SAS is so technical, not much help from online for complete beginners.

 

I'll read the link you gave. Thanks for the help.

Super User
Posts: 19,167

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

Sounds a bit like real life, here's the tools, here's the problem, give me a solution by Friday Smiley Very Happy

 

Here's a link to the video tutorials on basic SAS programming:

http://video.sas.com/#category/videos/sas-analytics-u

 

You can find papers on any topic here - user written so the quality can vary a bit. Papers from SAS Global Forum are likely to be a bit better quality or if you want to spend some money, the Little SAS Book is a great reference and tutorial.

 

lexjansen.com

 

 

Super User
Posts: 19,167

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

Oh, and a data set name cannot start with a number. You'll get an error there.
Highlighted
Trusted Advisor
Posts: 1,795

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

[ Edited ]

Why do it in a data step?

 

PROC CORR with the SSCP option will produce these values.

 

 

Super User
Posts: 19,167

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?


PaigeMiller wrote:

Why do it in a data step?

 

PROC CORR with the SSCP option will produce these values.

 

 


Because I didn't know that Smiley Happy

New Contributor
Posts: 4

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

[ Edited ]

Sxx is (xi-xbar)^2

 

Is this how I'd do a data step for it? Or would I use CSS? I'm sorry, but I don't understand anything with SAS. My professor is very unclear about everything. I'm only an undergraduate. 

 Proc Print; var (x-xbar)^2

 

Trusted Advisor
Posts: 1,795

Re: How to calculate Syy, Sxx, Sxy, x^2, etc?

[ Edited ]

taggerung wrote:

Sxx is (xi-xbar)^2

 

Is this how I'd do a data step for it? Or would I use CSS? I'm sorry, but I don't understand anything with SAS. My professor is very unclear about everything. I'm only an undergraduate. 

 Proc Print; var (x-xbar)^2

 


 

Well, I'm sorry your professor is being unreasonable, but you do need to understand what Sxx and Syy and Sxy are, otherwise you will never get the answers. You could (and I tried it, this works) type Sxx Syy Sxy into Google or other search engine. And so this isn't really a SAS problem at all.

 

Sxx is not (x-xbar)^2. It is the sum of squares of X — in other words (x-xbar)^2, summed across all ovservations

 

Similarly, Syy is as above, except for Y

 

Similarly, Sxy is (x-xbar)(y-ybar) summed across all observations.

 

Then we get to the SAS portion of the festivities.

 

PROC CORR with the SSCP option will give you these three items for your data.

 

 

 

 

Ask a Question
Discussion stats
  • 10 replies
  • 260 views
  • 4 likes
  • 3 in conversation