BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
taggerung
Calcite | Level 5

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...

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@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.

 

 

 

--
Paige Miller

View solution in original post

10 REPLIES 10
Reeza
Super User

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 🙂

 

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...

 

 


 

 

taggerung
Calcite | Level 5

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?

Reeza
Super User

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 🙂

taggerung
Calcite | Level 5

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.

Reeza
Super User

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.

 

lexjansen.com

 

 

Reeza
Super User
Oh, and a data set name cannot start with a number. You'll get an error there.
PaigeMiller
Diamond | Level 26

Why do it in a data step?

 

PROC CORR with the SSCP option will produce these values.

 

 

--
Paige Miller
Reeza
Super User

@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 🙂

taggerung
Calcite | Level 5

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

 

PaigeMiller
Diamond | Level 26

@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.

 

 

 

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 50644 views
  • 4 likes
  • 3 in conversation