|
Alternatively, if you can find a way to do this outside of macro code, the
iterative do statement in a data step DOES allow fractional increments:
On 10/2/06, toby dunn <tobydunn@hotmail.com> wrote:
>
> Minze ,
>
> No you cant to fractional values in a %Do Loop, why, well because the %Do
> Loop uses an implicit call to %Eval which only does integer values.
>
> Common way to over come this is:
>
> %Let Values = 0 0.5 1 ;
>
> %Do I = 1 To 3 ;
> %Put %Scan( &Values , &I , %Str( ) ) ;
> %End ;
>
>
>
>
> Toby Dunn
>
> When everything is coming at you all at once, your in the wrong lane.
>
> A truly happy person is someone who can smile and enjoy the scenery on a
> detour.
>
>
>
>
>
> From: Minze Su <slhappyls@GMAIL.COM>
> Reply-To: Minze Su <slhappyls@GMAIL.COM>
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: A question about %do %to statment in macro
> Date: Mon, 2 Oct 2006 17:05:51 -0400
>
> Dear all,
>
> I met the following problem:
>
> if I input this
>
> %macro outroc(dataset=ms.rocinput_mlr, stepsize=0.1, method='mlr');
>
>
> %do i=0 %to 1 %by 1;
> %put &stepsize.;
> %end;
>
> %mend outroc;
>
> It can give the right result. But if I change the step to 0.5.
>
> The log gives:
>
>
> ERROR: A character operand was found in the %EVAL function or %IF
> condition where a numeric
> operand is required. The condition was: 0.5
> ERROR: The %BY value of the %DO I loop is invalid.
> ERROR: The macro OUTROC will stop executing.
>
> Is it sas can not use a fractional value as step in do loop of Macro. Can
> anyone help?
>
> Thank you in advance
>
> Best regards,
>
> Minze
>
|