BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am trying to submit the following codes, but it always comes up with the error: ???

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
operand is required. The condition was: split-1
ERROR: The macro INFO will stop executing.


-------------------------------------------------------------------------------------------------



libname project 'F:\Courseinfo\fall2009\CS699\presentation';

%macro var_discret (var);

data pd_&var;
set project.pd_data_import (keep=&var status);
run;

proc sort data=pd_&var;
by &var;
run;

%macro info(split);

data _null_;
%let L_obs=%sysevalf(&split-1);
set pd_&var (firstobs=1 obs=&L_obs) end=lastobs;

if status=1 then count_yes+1;
else if status=0 then count_no+1;
if lastobs then do; p_yes=count_yes/&L_obs; p_no=count_no/&L_obs;entropy=-p_yes*log(p_yes)/log2-p_no*log(p_no)/log2;
call symput ('entropy_D1', trim(left(put(entropy,8.0)))); end;
run;

data _null_;
%let R_obs=%sysevalf(&split+1);
set pd_&var (firstobs=&R_obs obs=195) end=lastobs;

if status=1 then count_yes+1;
else if status=0 then count_no+1;
if lastobs then do; p_yes=count_yes/(196-&R_obs); p_no=count_no/(196-&R_obs);entropy=-p_yes*log(p_yes)/log2-p_no*log(p_no)/log2;
call symput ('entropy_D2', trim(left(put(entropy,8.0)))); end;
run;

%let info=%sysevalf((&L_obs/195)*&entropy_D1+((196-&R_obs)/195)*&entropy_D2);
%let previous_info=&info;
%mend;

%do split= 2 %to 194;
%info(split)
%if %sysevalf(&info lt &previous_info) %then %let final_split_pos_&var=&info;
%end;

%put "The final split point for variable &var is &split";
%mend;

%var_discret(MDVP_Fo)
1 REPLY 1
Flip
Fluorite | Level 6
You should be using %info(&split) not %info(split)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 535 views
  • 0 likes
  • 2 in conversation