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

Hi 

I am coming across this error when I run this:

 

PROC STEPDISC DATA=Yr2 method=stepwise SLE=.25 SLS=.15;
  VAR IT SEV;
  CLASS Yr_2BS101 Yr_2BS889 Yr_2DL560 Yr_2DL738 Yr_17; run;

I tried using this as a reference

https://communities.sas.com/t5/SAS-Programming/error-22-322-syntax-error-expecting-one-of-the-follow...

 

but it did not help.

 

Is this error saying I need to put another ";" or remove one?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @wkm21,

 

The documenation of the CLASS statement of PROC STEPDISC (which I have never used before) says that only one CLASS variable is allowed. You can have several quantitative variables in the VAR statement.

 

If you actually need more than one classification variable, then you must combine them first to a single CLASS variable before you can use them in PROC STEPDISC.

 

Example (an extension of Example 111.1 from the documentation):

data iris;
set sashelp.iris;
length subspecies $5;
subspecies=choosec(mod(_n_,2)+1,'minor','maior'); /* fictitious second classification variable */
run;

data want;
set iris;
length exactspecies $16;
exactspecies=catx('_',species,subspecies); /* combined classification variable */
run;

proc stepdisc data=want bsscp tsscp;
class exactspecies;
var SepalLength SepalWidth PetalLength PetalWidth;
run;

With "class species subspecies;" you would get the "ERROR 22-322: Expecting ;" pointing to the second CLASS variable.

View solution in original post

7 REPLIES 7
Patrick
Opal | Level 21

You need to run your code in a fresh new session and then look at the very first Warnings and especially Error that gets thrown.

Any later error is often a result of the first error. Resolve the first error and then re-run your code out of a new session (=if using EG or SAS Studio re-connect to the workspace server before running so nothing "messed-up" remains from your previous run).

 

If you still struggle to resolve the issue then share your code and the log portion which shows the first error message (not only the message but at least also the portion from the log where SAS tells you where in the code the error occurs).

wkm21
Calcite | Level 5
Hi
Let me ask in the code I gave above the section where it says VAR --- do you put predictors (non-response variables) there?
Patrick
Opal | Level 21

Run the code in a fresh new session, share the code and SAS log portion of first error encountered with us - else it's too much guessing.

 

Eventually attach the SAS log and code so the Body of the discussion here doesn't get "blown up".

wkm21
Calcite | Level 5
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         data Yr1;
 74         input LINE$ IT SEV Yr_2BS101$ Yr_2BS889$ Yr_2DL560$ Yr_2DL738$ Yr_17$ ;
 75         datalines;
 
 NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
 NOTE: The data set WORK.YR1 has 96 observations and 8 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              688.46k
       OS Memory           31656.00k
       Timestamp           04/25/2021 09:31:50 PM
       Step Count                        146  Switch Count  2
       Page Faults                       0
       Page Reclaims                     147
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 173        ;
 174        run;
 175        
 176        PROC PRINT data=Yr1;  run;
 
 NOTE: There were 96 observations read from the data set WORK.YR1.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.24 seconds
       user cpu time       0.24 seconds
       system cpu time     0.00 seconds
       memory              4182.43k
       OS Memory           33960.00k
       Timestamp           04/25/2021 09:31:50 PM
       Step Count                        147  Switch Count  0
       Page Faults                       0
       Page Reclaims                     580
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           80
       
 
 177        
 178        
 179        data Yr2;
 180        set Yr1;
 181        if Yr_2BS889 = 'NA' then Yr_2BS889 = ' ';
 182        if Yr_2BS101 = 'NA' then Yr_2BS101 = ' ';
 183        if Yr_2DL560 = 'NA' then Yr_2DL560 = ' ';
 184        if Yr_2DL738 = 'NA' then Yr_2DL738 = ' ';
 185        if Yr_17 = 'NA' then Yr_17 = ' ';
 186        run;
 
 NOTE: There were 96 observations read from the data set WORK.YR1.
 NOTE: The data set WORK.YR2 has 96 observations and 8 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              963.40k
       OS Memory           34220.00k
       Timestamp           04/25/2021 09:31:50 PM
       Step Count                        148  Switch Count  2
       Page Faults                       0
       Page Reclaims                     133
       Page Swaps                        0
       Voluntary Context Switches        18
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           272
       
 
 187        
 188        PROC PRINT data=Yr2;  run;
 
 NOTE: There were 96 observations read from the data set WORK.YR2.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.21 seconds
       user cpu time       0.21 seconds
       system cpu time     0.00 seconds
       memory              789.56k
       OS Memory           34216.00k
       Timestamp           04/25/2021 09:31:50 PM
       Step Count                        149  Switch Count  0
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           80
       
 
 188      !                           
 189        
 190        PROC STEPDISC DATA=Yr2 method=stepwise SLE=.25 SLS=.15;
 191          VAR IT SEV;
 192          CLASS Yr_2BS101 Yr_2BS889 Yr_2DL560 Yr_2DL738 Yr_17; run;
                              _________
                              22
                              76
 
 ERROR 22-322: Expecting ;.  
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE STEPDISC used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              444.03k
       OS Memory           34216.00k
       Timestamp           04/25/2021 09:31:50 PM
       Step Count                        150  Switch Count  0
       Page Faults                       0
       Page Reclaims                     48
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 193        
 194        
 195        
 196        
 197        
 198        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 210        

Hi

I ran a new session and did not notice any other key errors .

Here is the log:

Here is the code- The Yr## variables are non-numerical.

 

data Yr1;
input LINE$ IT SEV Yr_2BS101$ Yr_2BS889$ Yr_2DL560$ Yr_2DL738$ Yr_17$ ;
datalines;

LINE-147 54.64525075 7.092463884 NA 2 2 2 0
LINE-10 25.88450024 5.074078647 0 0 0 NA 1
LINE-100 27.14608229 4.850652121 0 0 0 0 0
LINE-103B 40.34453562 5.654304113 0 0 1 0 0
LINE-105 43.56203385 6.371383091 0 0 2 2 0
LINE-107 27.57597958 5.047991928 0 0 0 0 0
LINE-109 34.31976474 6.15718814 0 0 2 0 2
LINE-112 32.2334549 6.081084334 0 0 2 1 2
LINE-113 42.50141377 5.994849882 0 0 2 2 0
LINE-114 35.41432295 5.000280782 0 0 0 0 0
LINE-115 30.70192584 5.398471564 0 0 0 0 0
LINE-116 22.35356396 4.494664154 0 0 1 0 2
LINE-117 37.71368938 5.604462339 0 0 0 0 0
LINE-120 33.1457081 5.123920421 0 1 0 0 2
LINE-125 41.2793336 5.94896172 0 0 2 2 2
LINE-126 26.95108039 5.182851942 0 0 2 2 2
LINE-127 29.52382656 4.829627589 0 0 1 0 1
LINE-128 29.05892857 5.264727544 0 0 1 0 0
LINE-13 35.41432295 5.569124757 0 2 1 0 0
LINE-130 41.30481933 6.479275117 0 0 2 2 2
LINE-133 47.98344167 6.194588527 0 0 2 2 0
LINE-134 19.84575144 5.182851942 0 0 1 0 0
LINE-135 31.28091295 4.947125857 0 0 0 0 2
LINE-136 33.79422399 5.486599296 0 0 2 2 2
LINE-137 27.25753607 5.006057378 0 0 2 2 2
LINE-138 34.82527331 5.512240359 0 0 1 0 0
LINE-148 37.95885392 5.686337941 0 0 2 2 2
LINE-15 37.48621442 5.984377785 0 0 0 0 0
LINE-152 46.24439606 6.217532608 0 0 2 2 0
LINE-157 30.11358858 5.319705454 0 0 2 2 2
LINE-159 44.19510551 6.767888846 0 0 2 2 0
LINE-16 20.57469079 4.888194335 0 0 2 2 2
LINE-168 27.58198125 5.319705454 0 0 0 0 2
LINE-17 26.95251064 5.437568496 0 NA 0 NA 0
LINE-170 37.00388236 6.489246134 0 2 2 2 2
LINE-173 17.92155694 4.534605207 0 0 0 0 2
LINE-174 36.75775553 6.149052338 0 0 2 2 0
LINE-179 25.52671053 4.929502014 0 0 0 0 2
LINE-180 39.42860689 6.020678619 0 0 1 1 0
LINE-180B 40.59795976 6.024199937 0 0 0 0 0
LINE-182 44.3696819 6.855107788 0 0 2 2 0
LINE-182B 54.02829152 7.048119092 0 0 2 2 0
LINE-184 29.5770391 5.314623169 0 0 2 2 2
LINE-185 29.94264868 5.355523216 0 0 2 2 2
LINE-186 38.14860479 6.710831387 0 2 2 2 2
LINE-189 27.77476826 5.129097327 0 0 1 0 2
LINE-19 46.19475988 6.557267402 0 0 2 2 0
LINE-190 37.89286736 5.442996887 0 0 2 2 2
LINE-192 35.08847343 5.892304901 0 0 2 2 2
LINE-195 18.91983013 4.2399476 0 0 0 0 2
LINE-197 36.92925164 5.689550268 0 0 0 0 0
LINE-198 33.50279601 5.837947182 0 0 2 2 1
LINE-21 29.28225505 4.911138416 0 0 0 0 2
LINE-211 46.59597194 6.321290476 0 0 2 2 0
LINE-22 38.30264583 6.020678619 0 0 2 2 2
LINE-23 25.8717188 4.545205602 0 0 NA 0 2
LINE-24 45.15243609 6.420413891 0 0 2 2 0
LINE-25 23.32977791 4.866357543 0 0 1 0 0
LINE-257 41.69883055 6.084865479 0 0 0 0 0
LINE-266 37.58119656 5.679246031 0 0 2 2 0
LINE-28 20.85862713 4.425831912 0 0 2 0 0
LINE-30 37.14762141 5.568474899 0 0 1 0 0
LINE-32 37.18147186 6.308621924 0 0 2 2 2
U8134-33 37.08960865 5.739777949 0 0 2 2 1
LINE-35 27.10872304 4.886511987 0 0 2 2 2
LINE-35B 26.22514859 4.317668012 0 0 2 2 2
LINE-39 20.29218469 4.2399476 0 0 1 0 2
LINE-41 39.10682623 6.262609796 0 0 2 2 2
LINE-43 24.98765254 4.570592647 0 0 1 0 0
LINE-45 19.33442034 4.298879121 0 0 1 0 0
LINE-46 35.6575889 4.888194335 0 0 0 0 0
LINE-49 35.74732317 6.054068835 0 0 NA NA 2
LINE-53 31.88002512 5.341587167 0 0 0 0 2
LINE-55 26.54826793 4.648514638 0 0 0 0 2
LINE-56 39.59537668 5.931964748 0 0 2 2 2
LINE-58 38.90428204 6.203678274 0 0 1 0 0
LINE-59 14.95333021 4.008191445 0 0 1 1 2
LINE-60 22.85045922 4.534605207 0 0 1 0 2
LINE-63 46.20494299 6.371383091 0 0 2 2 0
LINE-65 20.17171393 4.545205602 0 0 1 0 0
LINE-69 49.36745118 6.792993488 0 0 2 2 0
LINE-7 15.52448723 4.351820282 0 0 2 2 0
LINE-72 31.58457583 4.658974397 0 0 0 0 0
LINE-86 33.485903 5.200384594 0 2 1 0 0
LINE-9 38.70279362 5.61436306 0 0 2 2 0
LINE-92 28.39743679 5.025047847 0 0 2 2 2
LINE-1 49.46642891 6.784446491 1 NA 2 NA 0
LINE-101 47.17728641 6.5364928 1 1 1 1 2
LINE-112B 44.6665791 6.825242243 1 2 NA 1 1
LINE-118B 35.87495531 5.980995548 1 1 1 1 1
LINE-150 31.92410843 5.654304113 1 1 2 2 2
LINE-176 35.6499428 5.512240359 1 NA NA NA 2
LINE-18 45.06399517 5.837332526 1 0 NA NA 2
LINE-199 29.21674088 5.89993092 1 2 1 1 2
LINE-2 37.88833143 5.796662347 1 0 2 2 0
LINE-212B 24.6313384 4.809856369 1 1 0 0 2
;
run;

PROC PRINT data=Yr1;  run;


data Yr2;
set Yr1;
if Yr_2BS889 = 'NA' then Yr_2BS889 = ' ';
if Yr_2BS101 = 'NA' then Yr_2BS101 = ' ';
if Yr_2DL560 = 'NA' then Yr_2DL560 = ' ';
if Yr_2DL738 = 'NA' then Yr_2DL738 = ' ';
if Yr_17 = 'NA' then Yr_17 = ' ';
run; 
	
PROC PRINT data=Yr2;  run;	
	
PROC STEPDISC DATA=Yr2 method=stepwise SLE=.25 SLS=.15;
  VAR IT SEV;
  CLASS Yr_2BS101 Yr_2BS889 Yr_2DL560 Yr_2DL738 Yr_17; run;



FreelanceReinh
Jade | Level 19

As I pointed out in my previous reply, you can use only one classification variable at a time in the CLASS statement of PROC STEPDISC. This could be one of the Yr... variables (i.e., one per PROC STEPDISC step) or a combination, e.g. concatenation, of two or more of these variables (if that makes sense from the statistical point of view) as shown in the example with the sashelp.iris data. Note that the procedure will exclude observations with missing values in the CLASS variable (the blanks that you introduced in the second DATA step). See "Number of Observations Used ..." in the procedure output and warnings in the log.

 

Also note that your first DATA step truncates values for variable LINE from 9 to 8 characters (e.g.  LINE-180B). Use a LENGTH statement or an informat specification (input LINE :$9. ...) to avoid this.

FreelanceReinh
Jade | Level 19

Hi @wkm21,

 

The documenation of the CLASS statement of PROC STEPDISC (which I have never used before) says that only one CLASS variable is allowed. You can have several quantitative variables in the VAR statement.

 

If you actually need more than one classification variable, then you must combine them first to a single CLASS variable before you can use them in PROC STEPDISC.

 

Example (an extension of Example 111.1 from the documentation):

data iris;
set sashelp.iris;
length subspecies $5;
subspecies=choosec(mod(_n_,2)+1,'minor','maior'); /* fictitious second classification variable */
run;

data want;
set iris;
length exactspecies $16;
exactspecies=catx('_',species,subspecies); /* combined classification variable */
run;

proc stepdisc data=want bsscp tsscp;
class exactspecies;
var SepalLength SepalWidth PetalLength PetalWidth;
run;

With "class species subspecies;" you would get the "ERROR 22-322: Expecting ;" pointing to the second CLASS variable.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1624 views
  • 6 likes
  • 4 in conversation