Dear SAS users,
I am running the following code:
%macro do_all;
%do i=0 %to 1 %by 0.25;
options mprint symbolgen;
Data c_&i;
set individuals;
contractbypc=&i;
keep klantnummer treated year contractbypc;
run;
%end;
%mend do_all;
%do_all;
I am getting the following error msg:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
.25
ERROR: The %BY value of the %DO I loop is invalid.
ERROR: The macro DO_ALL will stop executing.
I know its the %by part of the statement than is wrong, but I don't know how to fix it.
Thanks for your help.
K.
You can't use fractional or decimal arithmetic in a macro %DO statement. You can only use integers. Here is a solution to use non-integer values in a %DO statement: http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=p02f7difkhfytsn1dzhaas0rdf4n.htm&docset...
You can't use fractional or decimal arithmetic in a macro %DO statement. You can only use integers. Here is a solution to use non-integer values in a %DO statement: http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=p02f7difkhfytsn1dzhaas0rdf4n.htm&docset...
You can't call a dataset c_0.25 for example either. Why do you want to split similar data out in the first place, it just makes any further code much harder to write and takes more disk space?
I suppose you could do:
data _null_; do i=0 to 1 by 0.25; call execute(cats('data c_',tranwrd(put(i,best.),".","_"),'; set individuals; where contractbypc=',put(i,best.),'; run;')); end; run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.