BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rylife
Fluorite | Level 6
Original Code
 
Data scoredata_ifthen;
set scoredata0;
TotalScore= sum(score1, score2, score3);
AverageScore= mean(score1, score2, score3);
/* Using the IF...THEN...statement*/
IF gender ='m' THEN gender_num=1;
IF score1 NE. AND score2 NE. AND score3 NE. THEN take='complete';
IF AverageScore GE 90 THEN DO;
grade= 'A';
pass= 'pass';
END;
run;
 
 
After running code
OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 Data scoredata_ifthen;
74 set scoredata0;
75 TotalScore= sum(score1, score2, score3);
76 AverageScore= mean(score1, score2, score3);
77 /* Using the IF...THEN...statement*/
78 IF gender ='m' THEN gender_num=1;
79 IF score1 NE. AND score2 NE. AND score3 NE. THEN take='complete';
___
388
201
76
ERROR 388-185: Expecting an arithmetic operator.
 
ERROR 201-322: The option is not recognized and will be ignored.
 
ERROR 76-322: Syntax error, statement will be ignored.
 
80 IF AverageScore GE 90 THEN DO;
81 grade= 'A';
82 pass= 'pass';
83 END;
84 run;
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

correction;

 

you missed a blank in NE.  that is between NE and .

 

IF score1 NE . AND score2 NE . AND score3 NE . THEN take='complete';

Your original code below

IF score1 NE. AND score2 NE. AND score3 NE. THEN take='complete';

is causing tokenizaion problem at compile time

 

 

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20

correction;

 

you missed a blank in NE.  that is between NE and .

 

IF score1 NE . AND score2 NE . AND score3 NE . THEN take='complete';

Your original code below

IF score1 NE. AND score2 NE. AND score3 NE. THEN take='complete';

is causing tokenizaion problem at compile time

 

 

rylife
Fluorite | Level 6
Thank you!
Amir
PROC Star

@novinosrin has identified the issue and corrective action.

 

As an alternative, one can also make use of the missing function, e.g.:

 

if not missing(score1) and not missing(score2) and not missing(score3) then take='complete';

or, in your specific case, the nmiss function could also be of help, as it counts the number of missing numeric values, e.g.:

 

if nmiss(score1,score2,score3) eq 0 then take='complete';

 

Regards,

Amir.

 

rylife
Fluorite | Level 6

Thank you!

ballardw
Super User

If you want to do something when all values of numeric values are present you might want to consider the NMISS function instead of a bunch of If this and that and somethinelse comparisons:

 

If Nmiss(Score1, score2, score3) = 0 then take='complete';

 

if you have a lot of value you can even use list notation to reduce coding such as:

 

if nmiss( of score1-score25) =0 then take='complete';

which would certainly be a whole lot easier than 25 AND comparisons.

rylife
Fluorite | Level 6

Thank you, this will be useful once I use larger data sets. 

 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 6 replies
  • 20033 views
  • 3 likes
  • 4 in conversation