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

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

Data set name is have:

PaulN_1-1670279697264.png

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?

 

 

PaulN_0-1670279610465.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
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;

Ksharp_0-1670326989087.png

 

View solution in original post

5 REPLIES 5
ballardw
Super User

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.

PaulN
Obsidian | Level 7

&rho is a macro variable that I define as:

%let rho=0.5;

Thanks for the help.  

phongmarketing
Calcite | Level 5
it's so usefull, thanks u
Ksharp
Super User
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;

Ksharp_0-1670326989087.png

 

PaulN
Obsidian | Level 7

Thank you.  

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 5 replies
  • 433 views
  • 1 like
  • 4 in conversation