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;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 795 views
  • 0 likes
  • 2 in conversation