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...
@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. From the doc for PROC CORR:
SSCP
displays a table of the sums of squares and crossproducts. When you specify the SSCP option, the Pearson correlations are also displayed. If you specify the OUTP= option, the output data set contains a SSCP matrix and the corresponding _TYPE_ variable value is 'SSCP.' If you use a PARTIAL statement, the unpartial SSCP matrix is displayed, and the output data set does not contain an SSCP matrix.
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.
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 🙂
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...
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?
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:
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 🙂
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.
Sounds a bit like real life, here's the tools, here's the problem, give me a solution by Friday 😄
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.
Why do it in a data step?
PROC CORR with the SSCP option will produce these values.
@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 🙂
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
@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. From the doc for PROC CORR:
SSCP
displays a table of the sums of squares and crossproducts. When you specify the SSCP option, the Pearson correlations are also displayed. If you specify the OUTP= option, the output data set contains a SSCP matrix and the corresponding _TYPE_ variable value is 'SSCP.' If you use a PARTIAL statement, the unpartial SSCP matrix is displayed, and the output data set does not contain an SSCP matrix.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.