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

Hi there - I'm a beginner with SAS (on a Mac) and am trying to use proc logistic - but I keep getting error responses. My code is as below: 

 

data sasintro.data_clean;
set allpreg;
if qx17 ^=‘ ‘ then do;
Policy=0;
end;
if qx17="Yes" then Policy=1;
if index (qx22, "a") then comp=1;
else comp=0;
run;
proc logistic data=sasintro.data_clean descending;
model comp=Policy/rl;
run;
 
The log response is as below: 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 data sasintro.data_clean;
74 set allpreg;
75 if qx17 ^=‘ ‘ then do;
___
388
76
ERROR 388-185: Expecting an arithmetic operator.
 
ERROR 76-322: Syntax error, statement will be ignored.
 
76 Policy=0;
77 end;
___
161
ERROR 161-185: No matching DO/SELECT statement.
 
78 if qx17="Yes" then Policy=1;
79 if index (qx22, "a") then comp=1;
80 else comp=0;
81 run;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set SASINTRO.DATA_CLEAN may be incomplete. When this step was stopped there were 0 observations and 32 variables.
WARNING: Data set SASINTRO.DATA_CLEAN was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds
 
 
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
ERROR: Variable COMP not found.
NOTE: The SAS System stopped processing this step because of errors.
82 proc logistic data=sasintro.data_clean descending;
83 model comp=Policy/rl;
84 run;
85
86 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
98
 
Any help would be appreciated! Thank you! 
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
75 if qx17 ^=‘ ‘ then do;
___
388
76
ERROR 388-185: Expecting an arithmetic operator.

You are using "curly" quotes, these do not work inside of SAS. You need to use the straight quotes, which would look like this:

 

if qx17 ^=' ' then do;

Curly quotes often happen if your code is pasted into SAS from a word-processor or PowerPoint. Don't do this.

 

Futhermore, please help us out in the future by pasting the log file into the window that appears when you click on the {i} icon. This preserves the formatting of the log and makes it easier for us to read and decipher. DO NOT SKIP THIS STEP!

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
75 if qx17 ^=‘ ‘ then do;
___
388
76
ERROR 388-185: Expecting an arithmetic operator.

You are using "curly" quotes, these do not work inside of SAS. You need to use the straight quotes, which would look like this:

 

if qx17 ^=' ' then do;

Curly quotes often happen if your code is pasted into SAS from a word-processor or PowerPoint. Don't do this.

 

Futhermore, please help us out in the future by pasting the log file into the window that appears when you click on the {i} icon. This preserves the formatting of the log and makes it easier for us to read and decipher. DO NOT SKIP THIS STEP!

--
Paige Miller
rebecca8
Fluorite | Level 6

Thanks! That's funny - I was actually advised to use the curly quotes and had switched from straight ones. Thank you 🙂 

ballardw
Super User

@rebecca8 wrote:

Thanks! That's funny - I was actually advised to use the curly quotes and had switched from straight ones. Thank you 🙂 


You may want to go back to the source that recommended the curly quotes and see if they actually meant to use that for CODE statements or output appearance in a report.

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1096 views
  • 0 likes
  • 3 in conversation