Apologies for the uninformative title. This is actually a fairly simple problem which I could easily do myself in matlab or perhaps stata, but the professor demands it be in SAS, which seems to have been designed for robots not humans.
Say I have a matrix of farm output data with rows of crops at the farm and field level. For example, farm 1 has 3 fields so there are three rows for farm 1: $F_{11}, F_{12}, F_{13}$
A crop column indicates the crop grown on each field of each farm.
$F_{11}=corn$
$F_{12}=beans$
$F_{13}=squash$
(The crops would actually be represented by a numerical value.)
I need to come up with a SAS script that separates corn farms from non corn farms. I.e., I need to create a new binary cornfarm=0 or 1
variable. Corn farms are defined as any farm growing corn on any of its fields.
Corresponding pseudo-code would be something like this:
for i=1 to farmtotal
for j=1 to farmfieldtotal
if F(i,j)=corn then cornfield(i,j)=1
next j
if sum(cornfield(i))>0 then cornfarm(i)=1
next i