Hi everyone.
I have tried several different ways to get this to work. I can code it fine, but the current version of the code is really long and ugly. I know an array can fix it, but I cannot get it to work.
I have 38 monthly transaction fields labeled purch_201001 to purch_201302. I know that some of the data is invalid. I have a field called TARGET that identifies the last valid month of data. IE if the last valid month for the customer was Dec 2012, then TARGET=purch_201212. I need an array that will write over the remaining transaction fields with ".". In the example, it would overwrite purch_201301 and purch_201302, but the TARGET varies for other customers.
written out in long form it would be... if TARGET=purch_201212 then purch_201301=. and purch_201302=.; else if TARGET=purch_201301 then purch_201302=.; etc etc for all 38 months.
I know it's fairly simple array... but for whatever reason, I can't get it to work.
Any help is greatly appreciated!!!!
Thank you!
SS
This should work (untested) :
data want;
set have;
array purch{*} purch_:;
do _n_ = 1 to dim(purch);
if upcase(vname(purch{_n_})) > upcase(target) then call missing(purch{_n_});
end;
run;
PG
Perfect! Just had to make a small adjustment missing TARGETs and its working great.
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 16. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: