Converting two dimensional array into one dimensional in base SAS

Reply
Occasional Contributor
Posts: 10

Converting two dimensional array into one dimensional in base SAS

Hi,

I want to convert two dimensional array into single dimensional in base SAS.

Can anyone tell me if its possible.

Thanks In advance!

Dipti

Super User
Posts: 9,671

Re: Converting two dimensional array into one dimensional in base SAS

data _null_;

array x{2,3} (1 2 3 4 5 6);

array y{6};

do i=1 to dim1(x);

do j=1 to dim2(x);

k+1;

y{k}=x{i,j};

end;

end;

putlog y{*};

run;

Valued Guide
Posts: 2,174

Re: Converting two dimensional array into one dimensional in base SAS

If this is an array of variables (not a _temporary_ array) then just define the second array listing the same variables, and the "compiler" has done the conversion.

data demo ;

Set some.data ;

Array square(2,2) var1 var2 varX varY;

array vector(4)    var1 var2 varx vary ;

;;;;;;;;

Super User
Super User
Posts: 7,392

Re: Converting two dimensional array into one dimensional in base SAS

Hi,

Would need test data/example output to understand what you want.  Dimensions in arrays are just variables?

Ask a Question
Discussion stats
  • 3 replies
  • 180 views
  • 0 likes
  • 4 in conversation