Hi, I'm trying to loop over a string and assign a value based on whether the value is a number or a character e.g. data _null_; length Newcat $ 20; retain NewCat; Ref="123ABC"; do i=1 to length(Ref); val=substr(Ref,i,1); if val in ("1","2","3","4","5","6","7","8","9") then preCat="0"; else preCat="A"; NewCat=catt(NewCat,preCat); end; run; This correctly solves to NewCat="000AAA". The issue is that I need this to work in a data step on a dataset with a number of rows e.g. data t1; set Work.Data; do i=1 to length(Ref); length Newcat $ 20; val=substr(Ref,i,1); if val in ("1","2","3","4","5","6","7","8","9") then preCat="0"; else preCat="A"; NewCat=catt(NewCat,preCat); end; run; Any ideas would be massively appreciated. Thanks in advance. D.
... View more