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?
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;
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.
&rho is a macro variable that I define as:
%let rho=0.5;
Thanks for the help.
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;
Thank you.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.