BookmarkSubscribeRSS Feed
Obsidian | Level 7



%let ab= \\trg\mt-4tsr\stud\err\pgm\out


%macro tr(ds=);

    %if &ds. = &ab %then %do;

      data afg;







i am getting error


ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
operand is required. The condition was: &ds.=&ab.



Onyx | Level 15

Hi @sam1231 


1) there is semicolon missing in the %let statement

2) there is %end; missing in the macro code

3) make it:

%bquote(&ds.) = %bquote(&ab)

4) read this article:

5) and this article:


All the best




Polish SAS Users Group: and

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation

Super User

Adding to @yabwon 's recommendations for macro quoting papers:


All four are excellent papers, worth reading at least once a year. : )


BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page:
Diamond | Level 26

You might want to try this


%if %bquote(&ds) = %bquote(&ab) %then %do;

If that's not it, please turn on the debugging options as follows:


options mprint mlogic symbolgen;

run the code again, and show us the entire LOG file (not just the error messages) by clicking on the {i} icon and pasting the log into the window that appears. Do not skip this step.

Paige Miller

%BQUOTE should solve this.  Another easy way:


%if "&ds." = "&ab" %then %do;

The basic problem is that macro language sees the "-" in the middle of the string and decides that it needs to subtract.


The use of double quotes suppresses that interpretation of the "-" although it introduces complications if one or both strings contain leading or trailing blanks.

Super User

Fix the obvious ERRORs (missing semicolon and %end), and use quotes for the strings:

73         %let ab= \\trg\mt-4tsr\stud\err\pgm\out;
 75         %macro tr(ds=);
 76         %if "&ds." = "&ab" %then %do;
 77         data afg;
 78         set;
 79         run;
 80         %end;
 81         %mend;
 83         %tr(ds=&ab);
 NOTE: There were 428 observations read from the data set SASHELP.CARS.
 NOTE: The data set WORK.AFG has 428 observations and 15 variables.


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


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
  • 5 replies
  • 6 in conversation