BookmarkSubscribeRSS Feed
Dennis64
Calcite | Level 5

螢幕截圖 2021-10-22 下午5.49.52.png

C23005A6,3,15,,39

146DX2356,4,11,,,5

B36AA323,3,10,15,20

F123G246H1,1,

 

 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

What is the logic here? And where does F123G246H1 come from?

Kurt_Bremser
Super User

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.

Patrick
Opal | Level 21

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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 446 views
  • 0 likes
  • 4 in conversation