I have a dataset with values
as A,A,B,B,Z,Z,ZC,C,Z,Z
The output should be like this A,A,B,B,B,B,B,C,C,C,C
Data want;
set have;
retain new_var;
if var ne 'Z' then new_var=var;
run;
Explain your logic and problem in significantly more detail.
Hi I have a dataset "Products" which has a variable "Prod". This variable has got values
A
A
B
Z
Z
C
C
Z
Z
Whenever Z value comes up, like in this case Z has come up 4th observation, so it has to retain preceding value (B) and then again 5th observation is Z, since 4th obs has been replaced the 5th obs has also to be replaced with prior observation. When ever Z pops up it has to take preceding value
so the output is
A
A
B
B
C
C
C
C
Data want;
set have;
retain new_var;
if var ne 'Z' then new_var=var;
run;
thanks
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.