BookmarkSubscribeRSS Feed
rhapsody
Calcite | Level 5

I have an arrays like this

 

data prob_matrix;

set B_estimates;

  

 

array theta theta1-theta9;

 

end;

 

 

 

 Where theta1 to theta9 are 9 columns from a 9by9 matrix. Now I want to convert the Array theta into a long row. The resulting row vector is then 9*9=81 cells wide, since row 1,2 3 etc from theta are put next to eachother

 

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, I would advise that that is not the best layout, going the other way would be more beneficial, i.e. having 81 records and 2 columns.  Far easier to work with.  Anyways something like - and note that this is not tested as you have not provided test data in the form of a datastep.

 

data want (drop=i);
  set have end=last;
  array final{81} 8;
  retain final:;
  array theta{9};
  if _n_=1 then mult=0;
  do i=1 to 9;
    final{(mult*9)+i}=theta{i};
  end;
  if last then output;
run;

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 641 views
  • 0 likes
  • 2 in conversation