@sas_not_a_user wrote: Thank you @ballardw . Will follow code formatting going forward. To ask a bit more here: 1. isn't array med of size 12 being initialised with mth_01 to mth_12. And later one med{i} which is mth_01 to mth_12 being initialized with value 0. I'm confused because I can see in sample report out of the whole code, columns are being derived. So was confused with 0 intialization.
An ARRAY statement just tells the data step compiler which variables are meant when you use the array name in the code. So MED[4] is just another way to refer to MTH_04. It would only initialize those variables if you included the optional list of initial values after the list of variable names in the ARRAY statement.
However the assignment statement inside of the DO I=1 to 12 loop is where values are being to variables MTH_01 to MTH_12. Because this called when FIRST.INDIVIDUAL_ID is TRUE then it is done when you reach the first observation for that value of INDIVIDUAL_ID. You could call that DO loop the place where the values are initialized.
2. A statement like : (this piece of code is right above if last.individual_id line) < if (med_allowed ne 0) then med{diff+1} = med_allowed; medal1 = sum(medal1,med_allowed); /> to me it looks like med{diff+1} is initialised with med_allowed value, but doesn't seem being used. I can't understand if its author's way of code or its SAS way of doing. If I'm right, can you please confirm If i can read it as < if (med_allowed ne 0) ; medal1 = sum(medal1,med_allowed); /> P.S: This is very old code and can't reach to author. Thus asking for help here. thank you. I have used SAS documentation to understand concepts overallan and they have been helpful.
There is a big difference between an IF THEN statement and a subsetting IF statement. In an IF THEN statement if the condition is false only the statement after the THEN is skipped. With an subsetting IF statement if the condition is false the current iteration of the data step ends immediately and the data step moves directly to the next iteration, skipping any other statements (including any implied OUTPUT statement that is added to the end if the data step has no explicit OUTPUT statements).
We can't really tell if your substitution will end up doing the same thing without seeing the full data step. (And even then depending on the data they might end up doing the same thing, even if for a different input data they wouldn't).
... View more