BookmarkSubscribeRSS Feed
mding1
Calcite | Level 5

Hi all, 

I ran the below code:

proc reg data = wine;
model quality = alcohol 'volatile acidity'n sulphates 'total_sulfur dioxide'n chlorides pH 'sulphates total sulfur dioxide'n 'volatile acidity totsd'n 'alcohol sulphates'n 'sulphates pH'n/ influence;
output out = influencestats cookd = cooksd dffits = dffits h = hatmat p = preds r = resid;
rstudent = studdelresid student=studres;
run;

I got this error message:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         proc reg data = wine;
 70         model quality = alcohol 'volatile acidity'n sulphates 'total_sulfur dioxide'n chlorides pH 'sulphates total sulfur
 70       ! dioxide'n 'volatile acidity totsd'n 'alcohol sulphates'n 'sulphates pH'n/ influence; /* n = 20, p = 3*/
 ERROR: Variable 'total_sulfur dioxide'n not found.
 ERROR: Variable 'sulphates total sulfur dioxide'n not found.
 ERROR: Variable 'volatile acidity totsd'n not found.
 ERROR: Variable 'alcohol sulphates'n not found.
 ERROR: Variable 'sulphates pH'n not found.
 NOTE: The previous statement has been deleted.
 71         output out = influencestats cookd = cooksd dffits = dffits h = hatmat p = preds r = resid;
 72         rstudent = studdelresid student=studres;
            ________
            180
 NOTE: The previous statement has been deleted.
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 73         run;

 

And I checked the table contents, no variable name error here:

Screenshot 2023-07-29 at 12.47.07.png

 

How can I resolve the error in the code? Thanks in advance!!

 

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Hi

 

The first error you get

 

 ERROR: Variable 'total_sulfur dioxide'n not found.

 

is because you have typed an underscore between total and sulfur, and the variable name, as shown by PROC CONTENTS, does not have an underscore.

 

I can't tell about the other errors, as many of the variable names you have typed do not show up in the part of PROC CONTENTS that you have showed us, so I leave it up to you to investigate further.

--
Paige Miller
Tom
Super User Tom
Super User

Things to test.

1) Make sure you actually are using the same dataset as you ran the CONTENTS on.

2) That photograph looks like a picture of ODS output (probably HTML output). The ODS processor has a nasty habit of not displaying leading spaces.  So check to make sure the variable names do not have leading spaces that you need include in the name literals.  You could try printing the name values the $quote. format so that it prints quotes around the name.

Or perhaps just use the NLITERAL() function to print the name literals and then copy and paste the result into your code.

proc contents data=wine noprint out=contents; run;
data _null_;
  set contents;
  length nliteral $64 ;
  nliteral=nliteral(name);
  put nliteral;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 509 views
  • 0 likes
  • 3 in conversation