Errors in proc REG multiple regression syntax

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

Errors in proc REG multiple regression syntax

[ Edited ]

Please find my syntax below. The problem is as follows: A researcher was interested in predicting statistics final exam scores from students’ statistics anxiety scores, average number of minutes of study each week, and midterm exam scores. The following data were collected from a random sample of students

 

data case1;
output finalexamscore statsstressacore studyminutes midtermexamscore;
cards;

40 48 41 45
49 49 55 40
71 73 69 69
42 42 52 51
54 49 46 52
45 49 45 41
63 52 66 69
55 58 54 47
46 47 46 39
39 42 35 38
62 63 66 45
52 50 50 55
62 71 65 59
47 41 41 40
53 47 50 52
54 50 41 50
49 53 47 44
53 49 52 49
52 51 61 38
55 69 60 50

;
proc corr;
var finalexamscore statsstressacore studyminutes midtermexamscore;
proc reg;
model finalexamscore statsstressacore studyminutes midtermexamscore /stb scorr2 p r vif;
plot residual. * predicted.;
output out=res residual=resid predicted=pred;
proc univariate plot;
var resid;
run;


Accepted Solutions
Solution
‎04-17-2016 02:09 PM
Super User
Posts: 17,829

Re: Errors in proc REG multiple regression syntax

[ Edited ]

Fix the errors I mentioned in my first post. 

For your data step - it should be input not output - input reads data into SAS. 

 

As I mentioned isolate each error in turn going down and attempt to fix them. 

 

If if you still have errors post your code again. 

 

Also, consider comparing your current code to previous working code that worked and looking for differences. 

https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-SAS-Linear-regression-syntax-to-correc...

View solution in original post


All Replies
Super User
Posts: 17,829

Re: Errors in proc REG multiple regression syntax

[ Edited ]

Fix the errors by starting at the first one and moving forward. 

 

For or starters your model statement is incorrect. 

 

It it should be model dependentvar = list of independent var. 

You're missing the equal sign. I would also suggest running the base code and then building off from there. 

 

I domt believe there's a plot statement in proc REG the way you're using it. 

 

I also highly recommend including a Data= statement in your proc REG statement. It will use the last created data set but having it explicitly listed avoids errors. 

Contributor
Posts: 46

Re: Errors in proc REG multiple regression syntax

Thank you for your guidance Reeza. This is my log as requested.

NOTE: Copyright (c) 2002-2012 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1M2)
Licensed to UNIVERSITY OF SOUTH FLORIDA - SFA T&R, Site 70084813.
NOTE: This session is executing on the X64_ES08R2 platform.

 

NOTE: Updated analytical products:

SAS/STAT 13.2
SAS/ETS 13.2
SAS/OR 13.2
SAS/IML 13.2
SAS/QC 13.2

NOTE: Additional host information:

X64_ES08R2 WIN 6.1.7601 Service Pack 1 Server

NOTE: SAS initialization used:
real time 15.19 seconds
cpu time 1.68 seconds

ERROR: Permanent copy of file SASUSER.PROFBAK.CATALOG was deleted.
1 data case1;
2 output finalexamscore statsstressacore studyminutes midtermexamscore;
-------------- ---------------- ------------ ----------------
455 455 455 455
ERROR 455-185: Data set was not specified on the DATA statement.

3 cards;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.CASE1 may be incomplete. When this step was stopped there were 0
observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.13 seconds
cpu time 0.03 seconds

26 ;


27 proc corr;
28 var finalexamscore statsstressacore studyminutes midtermexamscore;
ERROR: Variable FINALEXAMSCORE not found.
ERROR: Variable STATSSTRESSACORE not found.
ERROR: Variable STUDYMINUTES not found.
ERROR: Variable MIDTERMEXAMSCORE not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE CORR used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

29 proc reg;
NOTE: Writing HTML Body file: sashtml.htm
30 model finalexamscore statsstressacore studyminutes midtermexamscore /stb scorr2 p r vif;
-
73
ERROR: Variable FINALEXAMSCORE not found.
ERROR: Variable STATSSTRESSACORE not found.
ERROR: Variable STUDYMINUTES not found.
ERROR: Variable MIDTERMEXAMSCORE not found.
NOTE: The previous statement has been deleted.
ERROR 73-322: Expecting an =.
31 plot residual. * predicted.;
32 output out=res residual=resid predicted=pred;

WARNING: No variables specified for an SSCP matrix. Execution terminating.
NOTE: The data set WORK.RES has 0 observations and 0 variables.
NOTE: PROCEDURE REG used (Total process time):
real time 6.22 seconds
cpu time 0.45 seconds


33 proc univariate plot;
34 var resid;
ERROR: Variable RESID not found.
35 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

Solution
‎04-17-2016 02:09 PM
Super User
Posts: 17,829

Re: Errors in proc REG multiple regression syntax

[ Edited ]

Fix the errors I mentioned in my first post. 

For your data step - it should be input not output - input reads data into SAS. 

 

As I mentioned isolate each error in turn going down and attempt to fix them. 

 

If if you still have errors post your code again. 

 

Also, consider comparing your current code to previous working code that worked and looking for differences. 

https://communities.sas.com/t5/SAS-Procedures/How-do-I-change-SAS-Linear-regression-syntax-to-correc...

Contributor
Posts: 46

Re: Errors in proc REG multiple regression syntax

Reeza,

 

Thank you very much for your guidance. I completed all errors as you suggested and ran the code. The output provided what was requested thank you. I will download the output if you wish to look at it.

 

Again thank you very much,

 

Josie

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 417 views
  • 0 likes
  • 2 in conversation