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

Hi,guys,

Here are my codes,

 

PROC REG DATA=DATASET;

MODEL Y = X M C1 C2;

TITLE 'REG OF Y';

RUN;

MODEL M = X D E XD XE;

TITLE 'REG OF M';

QUIT;

 

THE ERROR MESSAGE IN LOG IS"only variables in the VAR statement or in MODEL statements prior to the first RUN statement are available"

 

Is there any wrong in my codes?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

PROC REG is an interactive proc. This means you can continue to submit MODEL statements after the RUN statement. 

PROC REG also does row wise removal of data when any variable in the VAR or MODEL statement is missing. 

 

It only keeps the variables in the MODEL or VAR statement. So if the variable has not been used in the MODEL or VAR statement before the first RUN it cannot be used in the next step because it may not account for the missing values correctly. Or at least that's my guess as to why it's this way. 

 

You can just list all the variables in the VAR statement to get around this. 

 

*does not work;
proc reg data=sashelp.cars;
model msrp = invoice cylinders mpg_city mpg_highway;
run;
model msrp = weight invoice cylinders;
run;quit;

*does work;
proc reg data=sashelp.cars;
var msrp invoice cylinders mpg_city mpg_highway weight;
model msrp = invoice cylinders mpg_city mpg_highway;
run;
model msrp = weight invoice cylinders;
run;quit;

@benepoko wrote:

Hi,guys,

Here are my codes,

 

PROC REG DATA=DATASET;

MODEL Y = X M C1 C2;

TITLE 'REG OF Y';

RUN;

MODEL M = X D E XD XE;

TITLE 'REG OF M';

QUIT;

 

THE ERROR MESSAGE IN LOG IS"only variables in the VAR statement or in MODEL statements prior to the first RUN statement are available"

 

Is there any wrong in my codes?

Thanks in advance.


 

View solution in original post

2 REPLIES 2
learsaas
Quartz | Level 8
PROC REG DATA=DATASET;
	MODEL Y = X M C1 C2;
	TITLE 'REG OF Y';
run;
PROC REG DATA=DATASET;
	MODEL M = X D E XD XE;
	TITLE 'REG OF M';
run;
quit;
Reeza
Super User

PROC REG is an interactive proc. This means you can continue to submit MODEL statements after the RUN statement. 

PROC REG also does row wise removal of data when any variable in the VAR or MODEL statement is missing. 

 

It only keeps the variables in the MODEL or VAR statement. So if the variable has not been used in the MODEL or VAR statement before the first RUN it cannot be used in the next step because it may not account for the missing values correctly. Or at least that's my guess as to why it's this way. 

 

You can just list all the variables in the VAR statement to get around this. 

 

*does not work;
proc reg data=sashelp.cars;
model msrp = invoice cylinders mpg_city mpg_highway;
run;
model msrp = weight invoice cylinders;
run;quit;

*does work;
proc reg data=sashelp.cars;
var msrp invoice cylinders mpg_city mpg_highway weight;
model msrp = invoice cylinders mpg_city mpg_highway;
run;
model msrp = weight invoice cylinders;
run;quit;

@benepoko wrote:

Hi,guys,

Here are my codes,

 

PROC REG DATA=DATASET;

MODEL Y = X M C1 C2;

TITLE 'REG OF Y';

RUN;

MODEL M = X D E XD XE;

TITLE 'REG OF M';

QUIT;

 

THE ERROR MESSAGE IN LOG IS"only variables in the VAR statement or in MODEL statements prior to the first RUN statement are available"

 

Is there any wrong in my codes?

Thanks in advance.


 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 980 views
  • 0 likes
  • 3 in conversation