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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.