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

Hi all,

A basic question here. I have a VIX 2014 dataset, which is shown as:

datetauKcall_option_priceSrput_option_price
2014/1/216173598.61831.980.00182.175
2014/1/216174093.91831.980.00182.175
2014/1/216174588.851831.980.00182.525
2014/1/216175084.051831.980.00182.6
2014/1/216175579.41831.980.00182.825

...

2014/1/236174097.71831.980.00227.6
2014/1/236174593.41831.980.00228.05
2014/1/2361750891831.980.00228.55
2014/1/236175584.61831.980.00229.15
2014/1/236176080.251831.980.00229.8
2014/1/236176575.951831.980.002210.45
2014/1/236177071.51831.980.002211.25

...

2014/1/315173597.251831.370.00181.625
2014/1/315174092.61831.370.00181.775
2014/1/315174587.51831.370.00181.925
2014/1/315175082.651831.370.00181.925
2014/1/315175577.81831.370.00182.25
2014/1/3151760731831.370.00182.45
2014/1/315176568.451831.370.00182.75
2014/1/315177063.751831.370.00183.05
2014/1/315177559.051831.370.00183.375
2014/1/315178054.251831.370.00183.7

...

2014/1/335174096.451831.370.00226.9
2014/1/335174592.451831.370.00227.3
2014/1/335175087.951831.370.00227.85
2014/1/335175583.551831.370.00228.35
2014/1/335176079.21831.370.00229
2014/1/335176574.91831.370.00229.7
2014/1/335177070.651831.370.002210.4
2014/1/335177566.51831.370.002211.2
2014/1/335178062.41831.370.002212.1
2014/1/335178558.351831.370.002213.05

The data is imported by proc import. Just focus the variable 'tau', where is defined as the near-term expiration (T1) by tau=16 for 2014/1/2 and next-term expiration (T2) by tau=36 for 2014/1/2. Similarly, the T1 for 2014/1/3 is 15 and T2 for the same day is 35.

The question is, how can I extract the T1 and T2 with corresponding other variables in the same row separately into two different tables or matrixes? and make it is available to conduct matrix calculation, such as i = 0 to n,

Y = a*T1[ i ] * b*T2[ i ]  (Just a simple example, I have to conduct a complex calculation then)?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

I think you are asking how to extract the unique values of tau. Basically, this is a form of BY-group analysis. The easiest way (conceptually) is to use the UNIQUE-LOC technique to extract the rows that correspond to each level of the tau variable. The link includes an example.

 

For your data, you would locate the observations for each level of tau and then extract the relevant rows into a matrix. You didn't supply your IML program, but it might look something like this:

do i = 1 to ncol(u);     /* 4. For each level... */
   idx = loc(tau=u[i]);  /* 5. Find observations in level */
   A = x[idx, ];         /* 6. Extract rows of the X matrix into A */
/* now process and compute with the A matrix */ end;

 

It is not clear to me if you want to also read/process each date separately. If so, there is a slightly more complicated version of the UNIQUE-LOC technique that handles multiple BY-group variables

 

 

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Here's a simple example of IML code that subsets the input data set base upon a WHERE clause, that you can modify. It refers to a SAS dataset named SASHELP.CLASS, which you have. https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=imlug&docsetTarget=imlug_...

 

use Sashelp.Class var{name sex age} where(age>10);

 

Alternatively, you can place a WHERE clause in the IML READ statement. https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=imlug&docsetTarget=imlug_...

 

read all var {Weight} where(Sex='M'); /* vector of male weights */
--
Paige Miller
Rick_SAS
SAS Super FREQ

I think you are asking how to extract the unique values of tau. Basically, this is a form of BY-group analysis. The easiest way (conceptually) is to use the UNIQUE-LOC technique to extract the rows that correspond to each level of the tau variable. The link includes an example.

 

For your data, you would locate the observations for each level of tau and then extract the relevant rows into a matrix. You didn't supply your IML program, but it might look something like this:

do i = 1 to ncol(u);     /* 4. For each level... */
   idx = loc(tau=u[i]);  /* 5. Find observations in level */
   A = x[idx, ];         /* 6. Extract rows of the X matrix into A */
/* now process and compute with the A matrix */ end;

 

It is not clear to me if you want to also read/process each date separately. If so, there is a slightly more complicated version of the UNIQUE-LOC technique that handles multiple BY-group variables

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 626 views
  • 2 likes
  • 3 in conversation