|
Several solutions have been offered.
One thing which has been illustrated but not explicitly stated:
Coding can be easier and less error-prone if one chooses "self-sequencing"
variable names.
In this case, I would use something like: M02_01, M02_02, ... M02_12 for the
twelve months.
On Thu, 2 May 2002 11:24:15 -0700, Sheila Whitelaw <sw75@BOXFROG.COM> wrote:
>Hi, I need to assign a variable with the last non-blank value of
>monthly variables. I have the following code that works fine. I just
>wonder if there is a more efficient way to do it.
>
>data oset;
>set iset;
>if dec02^='' then prv=dec02;
>else if nov02^='' then prv=nov02;
>else if oct02^='' then prv=oct02;
>else if sep02^='' then prv=sep02;
>else if aug02^='' then prv=aug02;
>else if jul02^='' then prv=jul02;
>else if jun02^='' then prv=jun02;
>else if may02^='' then prv=may02;
>else if apr02^='' then prv=apr02;
>else if mar02^='' then prv=mar02;
>else if feb02^='' then prv=feb02;
>else if jan02^='' then prv=jan02;
>run;
>
>Thanks for any suggestion.
|