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

Dear all,

How are you?

I'm trying to run the code from this paper http://support.sas.com/resources/papers/proceedings14/2042-2014.pdf with my own data(8 5-level Likert items) but there is errors. Variable 'sumcor' seems like causing the problem. According to the paper, "Note that ∑ ∑ is just the sum of all values in the correlation matrix, since in a correlation matrix the diagonal elements are all 1, they sum to be the number of elements and the double sum adds up all off diagnonal elements (the correlations), note that each one would be repeated twice given the symmetry in the matrix."

I'm a novice user of proc iml and your help is greatly appreciated. 

I have printed out a partial log output FYI.

LOGIC(CALCALPHA.VARLIST):  %DO loop index variable I is now 8; loop will iterate again.

SYMBOLGEN:  Macro variable I resolves to 8

MLOGIC(CALCALPHA.VARLIST):  %DO loop index variable I is now 9; loop will not iterate again.

MPRINT(CALCALPHA.VARLIST):  rAttitudes01 rAttitudes02 rAttitudes03 rAttitudes04 rAttitudes05 rAttitudes06 rAttitudes07 rAttitudes08

MLOGIC(CALCALPHA.VARLIST):  Ending execution.

MPRINT(CALCALPHA):   } into itemcor;

SYMBOLGEN:  Macro variable QS resolves to rAttitudes

MPRINT(CALCALPHA):   section="rAttitudes";

SYMBOLGEN:  Macro variable CORDAT resolves to corrmatrix

MPRINT(CALCALPHA):   datused="corrmatrix";

MPRINT(CALCALPHA):   numbitem=trace(itemcor);

MPRINT(CALCALPHA):   one=j(numbitem,1);

MPRINT(CALCALPHA):   print 'The Input Correlation';

MPRINT(CALCALPHA):   print itemcor;

MPRINT(CALCALPHA):   print 'Number of items' numbitem;

MPRINT(CALCALPHA):   sumcor=(one)*itemcor*one;

ERROR: (execution) Matrices do not conform to the operation.


operation : * at line 4010 column 1

operands  : one, itemcor

one      7 rows      1 col     (numeric)

         1

         1

         1

         1

         1

         1

         1

itemcor      8 rows      8 cols    (numeric)

  0.999999 0.7418163 0.6005298 0.6328579 0.2149593 -0.085045 0.1591052 0.1087784

0.7418163  0.999999 0.6696118  0.639722 0.1674687 -0.127974 0.0821654 0.0697031

0.6005298 0.6696118  0.999999 0.8357702 0.2290657 -0.118532  0.136779    0.1264

0.6328579  0.639722 0.8357702  0.999999 0.2232193 -0.166345 0.1338478  0.137883

0.2149593 0.1674687 0.2290657 0.2232193  0.999999 -0.136473 -0.047612 0.1070489

-0.085045 -0.127974 -0.118532 -0.166345 -0.136473  0.999999 0.0824758 -0.076128

0.1591052 0.0821654  0.136779 0.1338478 -0.047612 0.0824758  0.999999  0.080517

0.1087784 0.0697031    0.1264  0.137883 0.1070489 -0.076128  0.080517  0.999999

statement : ASSIGN at line 4010 column 1

MPRINT(CALCALPHA):   alpha=(numbitem/(numbitem-1))*(1-(numbitem / sumcor));

ERROR: (execution) Matrix has not been set to a value.

operation : / at line 4010 column 1

operands  : numbitem, sumcor

numbitem      1 row       1 col     (numeric)

  7.999992

sumcor      0 row       0 col     (type ?, size 0)

statement : ASSIGN at line 4010 column 1

MPRINT(CALCALPHA):   print alpha;

ERROR: Matrix alpha has not been set to a value.

statement : PRINT at line 4010 column 1

MPRINT(CALCALPHA):   L = eigval(itemcor);

MPRINT(CALCALPHA):   theta=(numbitem/(numbitem-1))*(1-1/L[1]);

MPRINT(CALCALPHA):   print 'Theta';

MPRINT(CALCALPHA):   print theta;

SYMBOLGEN:  Macro variable OUT resolves to alpha

MPRINT(CALCALPHA):   create alpha var {section datused alpha theta};

MPRINT(CALCALPHA):   append;

SYMBOLGEN:  Macro variable OUT resolves to alpha

MPRINT(CALCALPHA):   close alpha;

NOTE: The data set WORK.ALPHA has 1 observations and 4 variables.

MPRINT(CALCALPHA):   quit;

NOTE: Exiting IML.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE IML used (Total process time):

      real time           0.06 seconds

      cpu time            0.06 seconds

MPRINT(CALCALPHA):   run;

MLOGIC(CALCALPHA):  Ending execution.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

COV2CORR is a 9.4 function.

There is an error in the code that reads

sumcor=(one)*itemcor*one;

It looks like the GRAVE accent mark (`) got deleted, perhaps when you copied the program from the PDF. It should be

sumcor=(one`)*itemcor*one;

or even better

sumcor=sum(itemcor);

Your life would be easier if the author posted her program to the SAS/IML File Exchange at:

http://communities.sas.com/sas-iml-file-exchange

Then you would not have to copy/paste from a PDF document where single and double quotes can get mangled.

View solution in original post

8 REPLIES 8
Rick_SAS
SAS Super FREQ

I don't know anything about the paper nor the subject area, but I think I can tell you how to fix the problem.

The error message says that the ONE vector has 7 items, whereas the ITEMCOR matrix is 8x8.  The diagonal elements of ITEMCORR are not 1. They are 0.99999. Therefore when you compute numbitem=trace(itemcor), you get 7.9999, which gets truncated to 7 in the statement one=j(numbitem,1);

I suggest that you replace the statement numbitem=trace(itemcor) with the statement numbitem=ncol(itemcor).

That should fix the problem.

Alternatively, you could use itemcor = cov2corr(x) if you want to make sure that the ITEMCOR matrix is a real correlation matrix.

Miracle
Barite | Level 11

Hi Rick.

Thanks for taking the time responding to my question.

The same errors are still there when I changed numbitem=trace(itemcor)=7.999992 to numbitem=ncol(itemcor)=8.


When I tried itemcor=cov2corr(x), it gives me ERROR: Invocation of unresolved module COV2CORR. I'm running SAS9.3TS Level 1M0 on W32_7PRO platform.


Thank you very much.

Rick_SAS
SAS Super FREQ

COV2CORR is a 9.4 function.

There is an error in the code that reads

sumcor=(one)*itemcor*one;

It looks like the GRAVE accent mark (`) got deleted, perhaps when you copied the program from the PDF. It should be

sumcor=(one`)*itemcor*one;

or even better

sumcor=sum(itemcor);

Your life would be easier if the author posted her program to the SAS/IML File Exchange at:

http://communities.sas.com/sas-iml-file-exchange

Then you would not have to copy/paste from a PDF document where single and double quotes can get mangled.

Miracle
Barite | Level 11

Thanks Rick. The code now runs without errors.


Sheraz
Calcite | Level 5

sir i am having the same problem;

I am doing AMMI analysis in SAS.

489  proc iml;

NOTE: IML Ready

490  use outres2;

491  read all into reside;

492  ngen=nrow(resid);

493  nenv=ncol(resid);

494  use stats2;

495  read var {mse} into msem;

496  read var {dfe} into dfem;

497  use stats3;

498  read var {nrep} into nrep;

499  call svd (U, L, V, resid);

ERROR: (execution) Matrix has not been set to a value.

operation : SVD at line 499 column 1

operands  : resid

resid      0 row       0 col     (type ?, size 0)

statement : CALL at line 499 column 1

500  minimo=min(ngen,nenv);

501  L=L[1:Minimo,];

ERROR: (execution) Matrix has not been set to a value.

operation : [ at line 501 column 4

operands  : L, *LIT1004, Minimo,

L      0 row       0 col     (type ?, size 0)

*LIT1004      1 row       1 col     (numeric)

         1

minimo      1 row       1 col     (numeric)

         0

statement : ASSIGN at line 501 column 1

502  ss =(L ## 2)*nrep;

ERROR: (execution) Matrix has not been set to a value.

operation : ## at line 502 column 1

operands  : L, *LIT1005

L      0 row       0 col     (type ?, size 0)

*LIT1005      1 row       1 col     (numeric)

         2

statement : ASSIGN at line 502 column 1

503  suma=sum(ss);

ERROR: (execution) Matrix has not been set to a value.

operation : SUM at line 503 column 9

operands  : ss

SS      0 row       0 col     (numeric)

statement : ASSIGN at line 503 column 1

504  porcent=((1/suma) # ss)*100;

ERROR: (execution) Matrix has not been set to a value.

operation : / at line 504 column 12

operands  : *LIT1006, suma

*LIT1006      1 row       1 col     (numeric)

         1

suma      0 row       0 col     (type ?, size 0)

statement : ASSIGN at line 504 column 1

505  porcenta=0;

506  do i=1 to minimo;

507  df=(ngen-1)+(nenv-1)-(2*i-1);

508  dfa=dfa//df;

509  porceacu=porcent[i,];

510  porcenta=porcenta+porceacu;

511  porcenac=porcenac//porcenta;

512  end;

513  options ps=5000 ls=78 nodate;

514  goptions device=cgmmwwc gsfname=biplot gsfmode=replace;

515  title1 'Analysis of Variance with the adjusted means';

516  title2 'no corrected by the number of replicates';

NOTE: Exiting IML.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE IML used (Total process time):

      real time           2:01:53.09

      cpu time            1:03.56

its the middle of code, i can send the whole code if needed ,

please help.

Rick_SAS
SAS Super FREQ

Your program has a typo. You are reading data into the vector RESIDE  (with an E at the end), but the remaining statements refer to the variable RESID (without an E). Change the second line of your program to

read all into resid;   /* delete the 'e' */

Sheraz
Calcite | Level 5

oh thanks sir, that error is gone but i got new error.

I am doing AMMI (additive main effect and multiplicative analysis interaction) analysis which is frequently used in Agricultural sciences/plant breeding.

The code is available here on page 14

http://www.iasri.res.in/sscnars/genetics/04-SAS%20for%20statistical%20genetics.pdf

if you could spare a couple of minutes and have a look of this code. it would be great.

can it be solved ?

attached is error log.

i am a beginner and trying for so many days.

please help!

Rick_SAS
SAS Super FREQ

If you are getting errors in a published macro, you should probably review the macro documentation and contact the person who wrote the macro if you still get errors.

From your error log, it looks like you have defined the variable NAME in the NAMEG dataset to be a numerical variable.

However, in the NAMEE dataset you have defined NAME to be a character variable. Therefore SAS complains when you try to append the data with the statement

SET NAMEG NAMEE;

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
  • 8 replies
  • 1879 views
  • 3 likes
  • 3 in conversation