arrays in SAS with more columns -


i have dataset

data have; input b c;  cards;  1 . . . . 1 1 1 . run; 

and looking output this.

a b c  out 1 . .  . . 1  c 1 1 . a,b 

i wrote program way:

data want; set have;  array u(3)a b c; i=1 3;  if u(i)^=. out=cat(vname(u(i),','); end;  run; 

this gives last vname , not concatenation.

when using separator concatenation, catx function use, or better call catx negates need put out = , using out in concatenation well. both these functions trim leading or trailing blanks.

the other problem code because out derived numeric variables, sas default type numeric well. need define type character beforehand (i've done length statement.

the following code achieves goal.

data have; input b c;  cards;  1 . . . . 1 1 1 . run;  data want; set have; length out $20; array u{3} b c; = 1 3; if not missing(u{i}) call catx(',',out,vname(u{i})); end; drop i; run; 

Comments