MARINO1982
Technical User
Hello there,
i'm new to SAS, as my organization recently switched from SPSS. Currently i've been able to do everything in SAS that i did in SPSS except for this.
For the sake of simplicity, let say i have sorted column 1 for which i took a subset and the corresponding column 2 of data attributed to it. I want to transform column 2 to compute column 3 (i.e where there is a zero i want the last non-zero preceeeding value). Now this could be done with the lag function if there was only one 0 following each non-zero value, however, as you can see there are cases with 'n' zero values follwing the non-zero. I can't use lagn either, because there may be cases where if i use LAG3, it will look too far back and pull the wrong non zero value.
a 1 1
a 0 1
a 2 2
a 0 2
a 0 2
a 3 3
a 0 3
a 0 3
a 0 3
4 4 4
I am DESPERATE for help on how to program SAS to accomplish this. Any help would be greatly appreciated!
Marino
i'm new to SAS, as my organization recently switched from SPSS. Currently i've been able to do everything in SAS that i did in SPSS except for this.
For the sake of simplicity, let say i have sorted column 1 for which i took a subset and the corresponding column 2 of data attributed to it. I want to transform column 2 to compute column 3 (i.e where there is a zero i want the last non-zero preceeeding value). Now this could be done with the lag function if there was only one 0 following each non-zero value, however, as you can see there are cases with 'n' zero values follwing the non-zero. I can't use lagn either, because there may be cases where if i use LAG3, it will look too far back and pull the wrong non zero value.
a 1 1
a 0 1
a 2 2
a 0 2
a 0 2
a 3 3
a 0 3
a 0 3
a 0 3
4 4 4
I am DESPERATE for help on how to program SAS to accomplish this. Any help would be greatly appreciated!
Marino