Thanks a lot. Matt's code works very well.
Could i use several 'for' arguments to get the results as what i think
first?

2009/7/28 John Kane <jrkrideau@yahoo.ca>

>
>  I see Matt Aldridge has given you the answers to your specific questions.
>
> If you are used to using SAS you might find Bob Meunchen's book "Muenchen,
> R. A. (2008). R for SAS and SPSS Users (1st ed.). Springer." useful.  A
> shorter version is available as a pdf at http://rforsasandspssusers.com/.
>  The pdf is a very useful guide for anyone beginning to use R.
>
> --- On Mon, 7/27/09, zhijie zhang <rusers.sh@gmail.com> wrote:
>
> > From: zhijie zhang <rusers.sh@gmail.com>
> > Subject: [R] How should i change the SAS Codes into R Codes?
> > To: r-help@stat.math.ethz.ch
> > Received: Monday, July 27, 2009, 11:03 AM
>  > Dear R users,
> >   I have a SAS codes with several loops in it, and i
> > hope to use R to do the
> > same task. The SAS codes are as follows,
> > /*to generate the dataset*/
> > DATA Single_Simulation;
> >  DO se=0 to 1 by 0.01;
> >   DO sp=0 to 1 by 0.01;
> >    DO DR=0 to 1 by 0.01;
> >     TR=(DR+sp-1)/(se+sp-1+1.0e-12);
> >     Adjust_Factor=TR/(DR+1.0e-12);
> >     OUTPUT;
> >    END;
> >   END;
> >  END;
> > RUN;
> >
> > /*to select some data*/
> > DATA sampledata;
> >  SET Single_Simulation;
> >  IF DR=0.02 & sp=1;
> > RUN;
> >
> > #I tried the following codes with R,failed
> > num<-seq(0, 1, by = 0.01)
> > for (se in num) {
> >  for (sp in num) {
> >    for (DR in num) {
> >     TR=(DR+sp-1)/(se+sp-1+1.0e-12)
> >     Adjust_Factor=TR/(DR+1.0e-12)
> >   }
> >  }
> > }
> >
> > My questions are,
> > 1. What is the correct codes for R to do the similar task?
> > 2. Sometimes, the simulated dataset are very large, so i
> > need to put the
> > generated dataset in a file with large disk place, not in
> > the memory, how to
> > do it? SAS can do it with the 'libname' argument,  do
> > R have the similar
> > method?
> >   Thanks a lot.
> >
>  >     [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org
> > mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained,
> > reproducible code.
> >
>
>
>      __________________________________________________________________
> Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your
> favourite sites. Download it now
> http://ca.toolbar.yahoo.com.
>

	[[alternative HTML version deleted]]


