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

I have a data set with more than 100 observations and contains three variables, var(x1), var(x2), and cov(x1, x2) in an excel file. How do I read this data set into SAS or SAS-IML to create a 2X2 matrix  with the variances on the diagonal and covariance off diagonal? I'm new to SAS and SAS-IML, and so, does anyone know of a "do-loop" to read these data into a matrix. Any help will be appreciated!

Thanks,

Rommel

1 ACCEPTED SOLUTION

Accepted Solutions
dessert_fox
Calcite | Level 5

Hi Sir Sylvain! Sorry if I had to ask you a more specific question related to the question I earlier asked. This is what my problem is:

I'm meta-analyzing effect sizes from more than 100 studies. Some studies have one effect size, or 2 effect sizes, or 3 effect sizes, and etc.

Because studies have different number of effect sizes, the covariance matrices of effect sizes are then different for each study.

To illustrate, I have small data set below (where Study 1 has 2 effect sizes, thus it has a 2X2 covariance matrix; Study has 3 effect sizes, thus

it has a 3X3 covariance matrix; and Study 1 (has 2 missing effect sizes) so it has only 1X1 covariance matrix). So here is my question Sir,

is there a code I can use to (automate) import the covariance matrix from say SAS to SAS-IML without having to type this covariance matrices

into SAS-IML, given the fact that I have more than 100 studies?

Study 1 = { .022 .009,

                   .009 .023}

Study 2 = { .016 .003 .006,

                  .003 .016 .008

                 .006 .008 .016}

  Study = { .019}

Thanks so much for the help. I'm new with SAS and SAS IML and I really need to figure out

how I can import my data (covariance matrices) in order for me to run an analysis.

Sincerely,

Rommel

View solution in original post

2 REPLIES 2
SylvainTremblay
SAS Employee

Hello,


SAS/IML comes with an interface: SAS/IML Studio. It implements IMLPlus, an enhanced version of the SAS/IML programming language.

In IMLPlus, you could use the DataObject.CreateFromExcelFile method in a program to read your MS Excel worksheet into SAS/IML Studio.


Otherwise, if you have the SAS/Access to PC Files module, you can use Proc IMPORT to import your MS Excel worksheet into a SAS dataset.

After, in SAS/IML, you can leverage the USE statement to open the dataset and make it current for input, then the READ statement to transfer the data from the dataset to a matrix.

Once in a matrix, you can manipulate the elements as you see fit.


Cheers!

Sylvain

dessert_fox
Calcite | Level 5

Hi Sir Sylvain! Sorry if I had to ask you a more specific question related to the question I earlier asked. This is what my problem is:

I'm meta-analyzing effect sizes from more than 100 studies. Some studies have one effect size, or 2 effect sizes, or 3 effect sizes, and etc.

Because studies have different number of effect sizes, the covariance matrices of effect sizes are then different for each study.

To illustrate, I have small data set below (where Study 1 has 2 effect sizes, thus it has a 2X2 covariance matrix; Study has 3 effect sizes, thus

it has a 3X3 covariance matrix; and Study 1 (has 2 missing effect sizes) so it has only 1X1 covariance matrix). So here is my question Sir,

is there a code I can use to (automate) import the covariance matrix from say SAS to SAS-IML without having to type this covariance matrices

into SAS-IML, given the fact that I have more than 100 studies?

Study 1 = { .022 .009,

                   .009 .023}

Study 2 = { .016 .003 .006,

                  .003 .016 .008

                 .006 .008 .016}

  Study = { .019}

Thanks so much for the help. I'm new with SAS and SAS IML and I really need to figure out

how I can import my data (covariance matrices) in order for me to run an analysis.

Sincerely,

Rommel

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2261 views
  • 0 likes
  • 2 in conversation