Obsidian | Level 7

## Producing a matrix of outcomes using PROBBNRM function.

Here's my data and program.  u1 and u2 are standard normal variables.

Data set name is have:

data cdf (keep=u1 u2 cdf);
set have;
cdf=probbnrm(u1, u2, &rho);
run;

proc transpose data=cdf;

by u1;

id u2;

run;

When I run the code it produces a matrix with the main diagonal terms (in yellow) but missing values for all others.  I've attempted a few other pieces of code but can't seem to get the output below.   Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Producing a matrix of outcomes using PROBBNRM function.

``````data have;
input id u1 u2;
cards;
1 -1.64 -2.05
2 -0.84 -1.4
3 -0.28 -0.91
4 0.12 -0.46
5 0.48 0
6 0.84 0.46
7 1.21 0.91
8 1.64 1.4
9 2.24 2.05
;
proc sql;
create table temp as
select *,probbnrm(u1, u2, 0.5) as cdf from
(select id ,u1 from have),(select u2 from have)
order by 1,2,3;
quit;
proc transpose data=temp out=want(drop=_name_) ;
by id;
var cdf;
run;

proc print noobs;run;``````

5 REPLIES 5
Super User

## Re: Producing a matrix of outcomes using PROBBNRM function.

Where does &rho come from? Are you expecting to use multiple values of rho?

Your code only uses one call to the function so only generates one output value per U1 U2 value pair.

Since I am not even going to try to retype all your values from a PICTURE, something similar to this may be what I think you are attempting. I am only using a few values of rho and not even attempting to "match" your want list.

```data junk;
input u1 u2;
do rho= .5 to 1 by .1;
cdf = probbnrm(u1, u2,rho);
idvar = cats('R',put(rho,4.1));
output;
end;
datalines;
-1.64485  -2.0537
-0.8416   -1.405
;

proc transpose data=junk out=trans ;
by u1 u2;
idlabel idvar;
var cdf;
run;```

This would require use of two BY variables in transpose.

Obsidian | Level 7

## Re: Producing a matrix of outcomes using PROBBNRM function.

&rho is a macro variable that I define as:

%let rho=0.5;

Thanks for the help.

Calcite | Level 5

## Re: Producing a matrix of outcomes using PROBBNRM function.

it's so usefull, thanks u
Super User

## Re: Producing a matrix of outcomes using PROBBNRM function.

``````data have;
input id u1 u2;
cards;
1 -1.64 -2.05
2 -0.84 -1.4
3 -0.28 -0.91
4 0.12 -0.46
5 0.48 0
6 0.84 0.46
7 1.21 0.91
8 1.64 1.4
9 2.24 2.05
;
proc sql;
create table temp as
select *,probbnrm(u1, u2, 0.5) as cdf from
(select id ,u1 from have),(select u2 from have)
order by 1,2,3;
quit;
proc transpose data=temp out=want(drop=_name_) ;
by id;
var cdf;
run;

proc print noobs;run;``````

Obsidian | Level 7

## Re: Producing a matrix of outcomes using PROBBNRM function.

Thank you.

Discussion stats
• 5 replies
• 471 views
• 1 like
• 4 in conversation