BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hdg
Obsidian | Level 7 hdg
Obsidian | Level 7

Hi, I have a fairly simple question.

I have a dataset say A

A looks like the below

a    h      j

1    0.5  0.6

0.3  1   0.7

0.3  0.9  1

I would like to subtract a number from each entry of A [ lets say subtract 1 from A] therefore

Anew looks like

a      h      j

0      -0.5  -0.4

-0.7   0      -0.3

-0.7    0.1    0

Then replace the diagonals of Anew with the diagonals of A therefore Anew looks like below

a      h      j

1      -0.5  -0.4

-0.7    1    -0.3

-0.7   0.1    1

There are only 3 columns but I can have any number of columns

Thanks so much for your help   

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

This would be extremely easy to do in PROC IML, if you have it available

Anew=A-1;

Anew2=Anew-diag(Anew)+diag(A);

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

This would be extremely easy to do in PROC IML, if you have it available

Anew=A-1;

Anew2=Anew-diag(Anew)+diag(A);

--
Paige Miller
hdg
Obsidian | Level 7 hdg
Obsidian | Level 7

Thanks for your help that is what I used too thought there may be something other than using IML.

PaigeMiller
Diamond | Level 26

You could do this in a data step but it's a little messier. Why do it in a data step if you already have something that works?

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 762 views
  • 0 likes
  • 2 in conversation