Hi,
   
  I am trying to change a SAS macro to R.
   
  here is my code. I get an error at the last line.
  attach(fram)
  dset1<-cbind(AGE,BMI,DEATH)
> BMIGRP<-cut(BMI,breaks=3,right=TRUE)
> AGEGRP<-floor(AGE/10)-2
> dset<-cbind(AGEGRP,BMIGRP,DEATH)
> maxage<-max(dset[,1])
> minage<-min(dset[,1])
> #maxcls<-dset[,2]
> #mincls<-dset[,2]
> nage<-maxage-minage+1
> nclass<-maxcls-mincls+1
> nsub<-nrow(dset)
> weight <- matrix(,nage,1)
> for ( i in minage:maxage )
+   {weight[i-minage+1,1] = sum(std = i)}
> 
>   atrisk = matrix(,nclass,nage)
>   wevents = matrix(,nclass,nage)
> #reduce data set to frequency table 
>  for( i in (minage : maxage))
+  for( j in (mincls : maxcls))
+ #atrisk1<-aggregate(dset[,c("AGEGRP","BMIGRP")],list(RANDID=dset1$RANDID,sum)
+ 
+     {atrisk[j-mincls+1,i-minage+1] =
+      sum((dset[,1]=i)& (dset[,2]=j))
+     wevents[j-mincls+1,i-minage+1]=
+       sum((dset[,1]=i)& (dset[,2]=j)&(dset[,3]=1))}
Error: subscript out of bounds
In addition: Warning messages:
1: numerical expression has 11627 elements: only the first used in: mincls:maxcls 
2: numerical expression has 11627 elements: only the first used in: mincls:maxcls 
   
  Any help will be greatly appreciated.
   
  Thanks,
  Anamika

		
---------------------------------

	[[alternative HTML version deleted]]


