C23005A6,3,15,,39
146DX2356,4,11,,,5
B36AA323,3,10,15,20
F123G246H1,1,
What is the logic here? And where does F123G246H1 come from?
Please do NOT present example data in pictures. Post a data step that creates the dataset from DATALINES, and post it in a code box (see your welcome mail). Otherwise a lot of time has to be wasted by the people trying to help you by setting up data for testing.
Please describe the logic for calculating and placing those numbers.
Providing the data in a friendlier form and a bit more description of the desired outcome would reduce guesswork and increase motivation to post an answer to your question.
Is below what you're after?
data have;
infile datalines truncover dsd dlm=',';
input customer_id :$20. var $ (unit1-unit4) (:best32.);
datalines;
C23005A6,3,15,,39
146DX2356,4,11,,,5
B36AA323,3,10,15,20
F123G246H1,1,
;
data want;
set have;
array _units {*} unit:;
do i=1 to dim(_units);
if not missing(_units[i]) then
do;
units_purchased=_units[i];
output;
end;
end;
keep customer_id units_purchased;
run;
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.