Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

do loops

Reply
Contributor
Posts: 31

do loops

can any one explain do loop working sceneria in follwing citation

data xx;

do i= 01 to 04;

j=01 to 04;

output;

end;

run;

Super User
Posts: 6,962

Re: do loops

There is no "working scenario", because:

20     do i= 01 to 04;
21   
22     j=01 to 04;
            __
            388
            202

ERROR 388-185: Expecting an arithmetic operator.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
SAS Employee
Posts: 11

Re: do loops

I think the program is either trying to do this:

data xx;

do i= 01 to 04;

j=i;

output;

end;

run;

or:

data xx;

do i= 01 to 04;

do j= 01 to 04;

output;

end;

end;

run;

Trusted Advisor
Posts: 1,131

Re: do loops

As per the code provided by @yeliu , first the internal do loop of j will execute and then the outer loop of i.

Thanks

Jag

Thanks,
Jag
Contributor
Posts: 31

Re: do loops

thanks for clarifying code however i am asking how works do loops in sas with diffrnc scenerios likewe put "output" after  "end"and before "end"

Super User
Super User
Posts: 6,502

Re: do loops

Why not just runs some test programs and find out?

Contributor
Posts: 31

Re: do loops

i had run some test programs but i can't understand do loop working method in sas

Contributor
Posts: 31

Re: do loops

can any one send link foe base do loops working method in

sas

Super User
Super User
Posts: 6,502

Re: do loops

Post an example of the code you tested and a specific question about it.

A simple iterative DO loop like in your original question work the same as in any other language.

The DO statement in SAS actual has many variations and can be extremely powerful, but without more details of what you are trying to do it is hard to give specific advice.

Here is link to on-line document for the iterative form of DO.

SAS(R) 9.4 Statements: Reference, Second Edition

Ask a Question
Discussion stats
  • 8 replies
  • 628 views
  • 0 likes
  • 5 in conversation