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

Dear Friends,

 

We are trying to create a three-dimensional plot of a variable – residsq - that is a function of two parameters.  The two parameters are sigma_T and sigma_Z.

 

Essentially, the two parameters will lie on the x and y axis and residsq will lie on z-axis. The two parameters are sigma_T and sigma_Z and we want them to vary from 0.1 to 10, in increments of 0.1

 

Note this is not a question about plotting it is about how to generate a variable.

 

In addition to the two parameters, residsq is a function of three variables that form a dataset of 14,000 observations.  The variables are ret, uep, and tq.  These variables are clearly fixed and are constant for different permutations of sigma_T and sigma_Z.

 

residsq has the following form:

 

residsq = [ret – (1 – 0.5*(sigma_T/1.0)) *uep – ((sigma_T*sqrt(1 – 0.5^2)))/sigma_Z)*tq]^2

 

Our output should look like this 3 column matrix:

 

sigma_T     sigma_Z    residsq

0.1               0.1              ?

0.2               0.1              ?

0.3               0.1               .

.                                       .

.

.

10.0              0.1

0.1               0.2

0.2               0.2

0.3               0.2

.

.

.10.0              0.2

.

.

 

Is there a way to do this in a data step or in proc iml?

 

 

Thanks so much for your help!

 

Srinivasan

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Something with a pair of nested loops perhaps:

 

data want;

   set have; /* assumes this is where the values for uep reside if not the statements like UEP = */

   do sigma_T = 0.1 to 10 by 0.1;

       do sigma_F = 0.1 to 10 by 0.1;

         <formula goes here>

         output;

      end;

   end;

run;

 

View solution in original post

4 REPLIES 4
WarrenKuhfeld
Rhodochrosite | Level 12

Yes.  Change '[' to '(', ']' to ')', '^' to '**', and put a semicolon at the end and you have a DATA step assignment statement.  Be sure to assign values to your other variables by using other assignment statements.  You can use IML, but a DATA step is a tiny bit easier for something like this.

srinirangan123
Fluorite | Level 6

Thanks a lot Warren!

 

Actually, the problem is that parameters sigma_F and sigma_T are not scalar constants.

 

I would like each of them range from 0.1 to 10 in increments of 0.1.

 

That means that they can each take 100 values.

 

In combination, I would 100 times 100 = 10,000 values.

 

So  essentially, I would like to create 10,000 values of the residsq vector (dimension 14,000 by 1)

 

I will then sum each of these 10,000 vectors to create 10,000 values of residq that correspond to each of the 10,000 combinations.

 

So I think a do loop would be needed.  

 

Thanks again for your help!

ballardw
Super User

Something with a pair of nested loops perhaps:

 

data want;

   set have; /* assumes this is where the values for uep reside if not the statements like UEP = */

   do sigma_T = 0.1 to 10 by 0.1;

       do sigma_F = 0.1 to 10 by 0.1;

         <formula goes here>

         output;

      end;

   end;

run;

 

srinirangan123
Fluorite | Level 6

Thanks a lot Ballardw.

 

That worked really well.

 

I appreciate it.

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!

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