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;
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.
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.