BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vicky07
Quartz | Level 8

Hello,

 

Can someone tell what I am doing wrong with the below macro? Long story short, I have a input dataset(i'm using cars dataset for illustration purposes) from which I want to extract rows from a starting position and end position. The start and end values could change every run hence I am using macro to the pass the start and end positions.

 

I am getting the below error message:

 

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 10 + 20 + 1
ERROR: Invalid number conversion on OBS.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 10 + 20 + 55

 

Thank you!

 

Code:

 

 

%let a = 10;
%let b = 20;
%let c = 55;

 

%Macro test(fst,lst);
Data temp;
Set sashelp.cars(firstobs=%eval(&fst. + 1) obs=%eval(&fst. + &lst.));
Run;


%Mend;

%test(%str(&a. + &b.),&c.)
;

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

You are quoting unnecessarily

try:

 

%test((&a. + &b.),&c.)  

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

You appear to be missing a space before the second dataset option name.

(firstobs=%eval(&fst. + 1)    obs=%eval(&fst. + &lst.))
novinosrin
Tourmaline | Level 20

You are quoting unnecessarily

try:

 

%test((&a. + &b.),&c.)  

vicky07
Quartz | Level 8
It worked, Thanks!!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1251 views
  • 3 likes
  • 3 in conversation