I'm doing a simulation exercise in my class and I have the codes for it and everything was running smoothly until I tried to run the last code I wrote. This is what I've done so far:
data samples;
do samp = 1 to 10;
do t = 1 to 100;
u = rannor(1996)*5;
x = 100 + 3*rannor(6991);
y = 10 + 0.5*x + u;
output;
end;
end;
run;
proc corr;
where samp=1;
var x y u;
run;
proc reg data=samples outest=bvalues outseb;
by samp;
model y = x;
run;
proc print data=bvalues;
run;
I had no issues running any of these codes until I tried to run this code next:
data one two;
set bvalues;
if_type_='PARMS' then output one;
else if_type_='SEB' then output two;
run;
proc print data=one;
proc print data=two;
run;
Then I got this error message:
data one two;
43 set bvalues;
44 if_type_='PARMS' then output one;
----
388
202
45 else if_type_='SEB' then output two;
---- ----
160 388
202
ERROR 388-185: Expecting an arithmetic operator.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
ERROR 160-185: No matching IF-THEN clause.
46 run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.ONE may be incomplete. When this step was stopped there were 0 observations and 9 variables.
WARNING: Data set WORK.ONE was not replaced because this step was stopped.
NOTE: No observations in data set WORK.ONE.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds
NOTE: No observations in data set WORK.TWO.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
What am I doing wrong here? I'm running the code exactly as directed in my assignment. I don't know how I'm messing up. Thanks guys.
Just a typo
you should leave a blank between if and _type_
see the correction-->
if _type_='PARMS' then output one;
else if _type_='SEB' then output two;
The error is
if_type_ as one word
Hello,
You need to be able to understand the log, which is great in SAS. Most of the errors in SAS shows with a bigger picture.
In your example, SAS is showing you on which line the error is encountered, and sometime you will have the solution withing the log info. Here it says IF-THEN, which means your IF-THEN statement is not properly defined.
44 if_type_='PARMS' then output one;
----
388
202
45 else if_type_='SEB' then output two;
---- ----
160 388
202
ERROR 388-185: Expecting an arithmetic operator.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
ERROR 160-185: No matching IF-THEN clause.
Please post code and especially log text into a code box opened using the forum's {I} icon. As you can see when you paste into the main message window that the code and log entries get reformatted by the forum software moving the underscore characters that indicate where issues occur.
data one two;
set bvalues;
if _type_='PARMS' then output one;
else if _type_='SEB' then output two;
run;
proc print data=one;
proc print data=two;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.