BookmarkSubscribeRSS Feed
Joliek44
Calcite | Level 5

Hello, 

I am trying to get p value and t values for given data. Every time I try to run my data, keeps giving me ERROR 22-322: Syntax error, expecting one of the following:  !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL,
NOTIN, OR, ^=, |, ||, ~=.

My SAS code is below. Any help would be appreciated. 

 

 

data A1;
n = 12;
mu0 = 241;
xbar = 235;
sd = 12.5;
se = sd/sqrt(n);
df = n-1
tval = (xbar-mu0)/se;
pval = (1-cdf('T',abs(tval),df))*2;
run;
proc print data=A1;
run;

3 REPLIES 3
ed_sas_member
Meteorite | Level 14

Hi @Joliek44 

 

it seems that you have a missing semi-colon at the end of the following statement:

df = n-1;

Best,

Joliek44
Calcite | Level 5

Hello, 

Oh my gosh. Yes! That was it. Thank you. I can't believe i overlooked that. 

ballardw
Super User

And why we indicate that with error messages you should post the LOG of the whole proc or data step that included the error:

 

462  data A1;
463  n = 12;
464  mu0 = 241;
465  xbar = 235;
466  sd = 12.5;
467  se = sd/sqrt(n);
468  df = n-1
469  tval = (xbar-mu0)/se;
     ----
     22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=,
              <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=,
              |, ||, ~=.

470  pval = (1-cdf('T',abs(tval),df))*2;
471  run;

The underscores appearing under the first element of the line means indicates that the previous line is expected to be continued and what you have doesn't fit in the possible syntax. So look to the previous line.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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