DATA Step, Macro, Functions and more

my do loop doesn't work. help me

Reply
Occasional Contributor
Posts: 11

my do loop doesn't work. help me


data room1 room2 room3 room4 room5 room6 room7 room8 ;
do i=1 to 8 ;
if rooms = i then output room(i) ;

end ;

run;

 

what should i do if i want to fix room(i) 

 

 

 

Respected Advisor
Posts: 2,794

Re: my do loop doesn't work. help me

Posted in reply to LeeSeongWoo_

This is not a direct answer to your question, but why do you need eight different data sets? You could keep all the data in one large data set and then do any subsequent processing with a BY statement. It's much simpler.

 

--
Paige Miller
Occasional Contributor
Posts: 11

Re: my do loop doesn't work. help me

Posted in reply to PaigeMiller

Thank you for your reply . but the file is too big 

Respected Advisor
Posts: 2,794

Re: my do loop doesn't work. help me

Posted in reply to LeeSeongWoo_

LeeSeongWoo_ wrote:

Thank you for your reply . but the file is too big 


Too big to do what? How do you know it is too big? Give us information, describe your actual problem instead of avoiding describing the problem.

--
Paige Miller
Super User
Posts: 13,283

Re: my do loop doesn't work. help me

Posted in reply to LeeSeongWoo_

LeeSeongWoo_ wrote:

Thank you for your reply . but the file is too big 


What is too big? You don't even reference a data set to read from to split into something smaller.

Super User
Super User
Posts: 9,384

Re: my do loop doesn't work. help me

Posted in reply to LeeSeongWoo_

As I posted in another thread today, splitting data out into multiple datasets is really not a good idea.

NOw to do what you want, you can't refere to dataset names by using array syntax,so please post an actual example, with test data in the form of a datastep where you would want to use this, as basically all your code below is doing is creating 8 datasets with one row each, which can be achieved by:

data room1 room2...;
run;

As you can see your example makes no sense at all.

 

Super User
Posts: 6,622

Re: my do loop doesn't work. help me

Posted in reply to LeeSeongWoo_

Do you have an existing data set that contains the variable ROOMS?  Right now, there is no data coming in via a SET or INPUT statement.

 

 

Regular Contributor
Posts: 227

Re: my do loop doesn't work. help me

Posted in reply to LeeSeongWoo_

"The file is *-always-* Too Big!"

 

macro calltext can do this trick.

 

see section 3.3 Splitting a Data Set

 

I agree with others: not a good idea to split a data set into subsets.

Figure out how to use either a by-statement or where clause.

 

Ron Fehd  macro function maven

Ask a Question
Discussion stats
  • 7 replies
  • 149 views
  • 1 like
  • 6 in conversation