0
votes

I have a SAS dataset like this:

 var1  var2 var3  var4  var5
there    is   no spoon   Neo

And want this:

var
thereisnospoonNeo

I have a data step like the following:

data want;
  set have;
  format var $100.;
  array v $ 5 var1-var5;
  var = "";
  do i=1 to 5;
    var = var || v{i};
  end;
run;

But my have has var = "";

1

1 Answers

0
votes

The issue is that the initial value of var is actually 100 characters of white space, and any concatenation truncates off the list. One must add

 var = strip(var) || v{i};

to achieve the desired result.