Hi! I am working on a sas code including a loop to make a sum of food intakes. Every subject has an ID and for each ID I have different strings, one for each food item consumed during the day. The goal is to obtain the total amount eaten every day by each subject, i.e.: the sum of each food variable for every ID. Here is the program I am using, which seems correct to me, but SAS keep saying that the variable first.id_no is not initialized: data dataset; set dataset; if first.id_no then do; sum0 = 0; sum1 = 0; sum2 = 0; sum3 = 0; end; sum0 = sum0 + intake*(vegetables = 1); sum1 = sum1 + intake*(fruit = 1); sum2 = sum2 + intake*(cereals = 1); sum3 = sum3 + intake*(fish = 1); run; Alternatively I have tried to write: if (first.id_no) then do; if first.id_no = 1 then do; always getting the same error message from SAS. Thanks for your help!
... View more