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-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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