Hi,
Can anyone help me where I am going wrong with the following code:
%let __tmpmv_dsid = %sysfunc(open(__tmpds_param_check));
%let __tmpmv_num = %sysfunc(varnum(&__tmpmv_dsid,si_unit));
%let __tmpmv_rc = %sysfunc(fetchobs(&__tmpmv_dsid,1));
%let __tmpmv_val = %sysfunc(getvarc(&__tmpmv_dsid,&__tmpmv_num));
%if not &__tmpmv_val %then %do;
%put %str (W)ARNING: SI Unit is not available for parameter: %nrbquote(¶m) ;
%put %str (W)ARNING: Raw unit will be used for CTCAE grade computation;
%let errcode = %eval(&errcode + 1);
%let __tmpmv_dsid = %sysfunc(close(&__tmpmv_dsid));
%end;
%else %let __tmpmv_dsid = %sysfunc(close(&__tmpmv_dsid));
I am getting ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: not &__tmpmv_val
Thanks in advance.
KC
While there is some debate on the best way, this is the way I prefer to check for blank vs. non-blank:
%if %length(&__tmpmv_val)=0 %then %do;
You can actually find an entire paper devoted to this subject.
Good luck.
What is the value of &__tmpm_val?
%put >>&__tmpmv_val.<< ;
From the message (and your code), since you are using GETVARC, it could a character value. The %IF statement is written as if it expects a Boolean value (0/1), or at least an integer that the macro language could treat as a Boolean.
28 %macro Check(p); 29 %if not &p %then %put true; 30 %else %put false; 31 %mend; 32 33 %check(1) false 34 %check(0) true 35 %check(9) false 36 %check(A) /*Error*/ ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: not &p ERROR: The macro CHECK will stop executing. 37 %check(1.) /*Error: %eval doesnt know about decimals*/ ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: not &p ERROR: The macro CHECK will stop executing.
Kind Regards,
--Q.
Hi Quentin,
Thanks, for your answer. My &__tmpmv_val is either blank (" ") or a char value (d/L, mg/dL etc).
What is the way out in these cases? Any alternative idea would be great too.
Many thanks,
DS
You can check for most BLANK conditions with
%if %sysevalf(%superq(macrovariablename)=,boolean)=1 %then %do
NOTE: the macrovariable name should not use the ¯ovariablename format. Look at the documentation of %superq.
While there is some debate on the best way, this is the way I prefer to check for blank vs. non-blank:
%if %length(&__tmpmv_val)=0 %then %do;
You can actually find an entire paper devoted to this subject.
Good luck.
OR
%if &__tmpmv_val eq %then.........
Thanks to everyone.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.