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

I do not want to duplicate messages but this has a different heading.

How can I fixed it?

LOG FILE:

NOTE: IML Ready

NOTE: Closing WORK.KMM_1

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

statement : CREATE at line 913 column 93

ERROR: No data set is currently open for output.

statement : APPEND at line 913 column 133

NOTE: Exiting IML.

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

NOTE: PROCEDURE IML used (Total process time):

      real time           0.00 seconds

      cpu time            0.01 seconds

CODE

proc iml;

use KMM_&p;

read all var{time censored  survival1 frequency y replicate } into DM;

/*read the 3 variables into matrix*/ /*have to print within DM*/

close;                                                                                     /*close the link between the dataset and IML*/

  replicate=DM[,6]; y=DM[,5];frequency =DM[,4]; survival1 =DM[,3]; Censored= DM[,2]; time = DM[,1];   /*Survivalival is second column*/  /*time is first column*/

n = nrow(DM);

/*number of rows in the dataset = obs*/ /*THE N DOESNT NEED TO BE FIXED*/

                     /*Segment equals the number of consecutive patterns*/ /*J creates a matrix in IML , it creates a 100x1 matrix of 1s, the 3rd 1 is the value in matrix*/

segment = J(nrow(DM),1,1); *print segment;

do k = 1 to ncol(u);

byIdx = loc(replicate=u); /* the UNIQUE-LOC trick */

byGroup = DM[idx,];

y=byGroup[,5];freqency =byGroup[,4]; survival1 =byGroup[,3]; Censored= byGroupDM[,2]; time = timeDM[,1];

do i = 2 to nrow(DM);

if ((Censored=1)=(Censored[i-1]=1)) then segment=segment[i-1];  /**/        /* coming up with unique segments for censored*****/;

else if ((Censored=1)=1-(Censored[i-1]=1)) then segment=segment[i-1]+1;

                     *print time survival1 censored frequency segment;                                

*print segment;

end;

    SurvivalM=J(nrow(survival1),1,1);

      do i = 1 to n;

         if censored=1 then SurvivalM=survival1; else if censored=0 then SurvivalM=survival1;  /*****Create a 1 by N -matrix of Survival ****/;

          

end;

 

      *print SurvivalM;

    InverseC=J(nrow(survival1),1,1);

   do i = 1 to n;

if censored=1 then InverseC=1/survival1; else if censored=0 then InverseC=0;  /*****survivalC is the imputed censored survival and set the real Survivalval to 1**/;

         end;

do i = 1 to ncol(frequency);

call symputx("j", i);

   m = num(symget("j"));

   m=1*m; print m;  %let mm=m;

end;

t=InverseC[(loc(InverseC^=0))]; print t;

tt=t(t); print tt;

Big=SurvivalM*(tt);

end;

create GIB_&p from BIG[colname={COL1}];                               

append from BIG;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions
IanWakeling
Barite | Level 11

Is the data the problem?  The vector 'replicate' copied from your input data set appears to have 7 unique values 1 to 7, so (u-1)*20 is a row vector with 7 values, which can not be added to the vector (1:20) as they do not conform.

View solution in original post

10 REPLIES 10
Rick_SAS
SAS Super FREQ

Your code has not defined u, therefore the DO loop over k is never executed and therefore Big is never defined.

As you develop this program, you will be more successfull if you start with a simple data set with two groups and a few observations in each group. It will be much easier for you to debug, and you could include the DATA step with future questions so that people on the list could actually run the complicated programs that you are posting.  Speaking for myself, I find it difficult to debug someone else's program when I have no idea what it is supposed to do and I can't even run it.

desireatem
Pyrite | Level 9

Thanks for the help, I defined u, yet still having issues;

LOG FILE:

NOTE: IML Ready

NOTE: Closing WORK.KMM_1

ERROR: (execution) Argument should be a scalar.

operation : J at line 5393 column 113

operands  : u, *LIT1010

u      1 row       7 cols    (numeric)

         1         2         3         4         5         6         7

*LIT1010      1 row       1 col     (numeric)

statement : ASSIGN at line 5393 column 105

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

operation : [ at line 5393 column 189

operands  : DM, idx,

DM    700 rows      6 cols    (numeric)

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

statement : ASSIGN at line 5393 column 177

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

CODE

proc iml;

use KMM_&p;

read all var{time censored  survival1 frequency y replicate } into DM;

/*read the 3 variables into matrix*/ /*have to print within DM*/

close;                                                                                     /*close the link between the dataset and IML*/

  replicate=DM[,6]; y=DM[,5];frequency =DM[,4]; survival1 =DM[,3]; Censored= DM[,2]; time = DM[,1];   /*Survivalival is second column*/  /*time is first column*/

n = nrow(DM);

/*number of rows in the dataset = obs*/ /*THE N DOESNT NEED TO BE FIXED*/

                     /*Segment equals the number of consecutive patterns*/ /*J creates a matrix in IML , it creates a 100x1 matrix of 1s, the 3rd 1 is the value in matrix*/

segment = J(nrow(DM),1,1); *print segment;

u = unique(replicate);

do k = 1 to ncol(u);

   byIdx = loc(replicate=u); /* the UNIQUE-LOC trick */

   byGroup = DM[idx,];          /* extract BY group */

y=byGroup[,5];freqency =byGroup[,4]; survival1 =byGroup[,3]; Censored= byGroupDM[,2]; time = timeDM[,1];

do i = 2 to nrow(DM);

if ((Censored=1)=(Censored[i-1]=1)) then segment=segment[i-1];  /**/        /* coming up with unique segments for censored*****/;

else if ((Censored=1)=1-(Censored[i-1]=1)) then segment=segment[i-1]+1;

                     *print time survival1 censored frequency segment;                                  

*print segment;

end;

    SurvivalM=J(nrow(survival1),1,1);

      do i = 1 to n;

         if censored=1 then SurvivalM=survival1; else if censored=0 then SurvivalM=survival1;  /*****Create a 1 by N -matrix of Survival ****/;

            

end;

   

      *print SurvivalM;

    InverseC=J(nrow(survival1),1,1);

   do i = 1 to n;

if censored=1 then InverseC=1/survival1; else if censored=0 then InverseC=0;  /*****survivalC is the imputed censored survival and set the real Survivalval to 1**/;

         end;

do i = 1 to ncol(frequency);

call symputx("j", i);

   m = num(symget("j"));

   m=1*m; print m;  %let mm=m;

end;

t=InverseC[(loc(InverseC^=0))]; print t;

tt=t(t); print tt;

Big=SurvivalM*(tt);

end;

create GIB_&p from BIG[colname={COL1}];                                 

append from BIG;

quit;

Rick_SAS
SAS Super FREQ

You should write

byGroup = DM[byIidx,];          /* extract BY group */

You will also have future problems if you don't fix the limits of the inner loops. You currently have

do i = 1 to n;

which is wrong because your vectors are now shorter than DM.I suspect that you want

do i = 1 to nrow(byGroup);

(or you can redefine n)

Now that you are on the right track, I'll let you and others debug your program. Take the time to learn how to interpret the ERROR messages that come out of PROC IML. This article might help: How to find and fix programming errors - The DO Loop

Good luck!

desireatem
Pyrite | Level 9

Thanks, I will look at and keep working on

desireatem
Pyrite | Level 9

Hi Rick, I am confused while I am still getting this error:

Thought this occurs when you try to assign or print a matrix that has not been assigned.:


NOTE: IML Ready

NOTE: Closing WORK.KMM_1

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

operation : [ at line 11381 column 173

operands  : DM, byIidx,

DM    700 rows      6 cols    (numeric)

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

statement : ASSIGN at line 11381 column 161

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

statement : CREATE at line 11388 column 94

ERROR: No data set is currently open for output.

statement : APPEND at line 11388 column 134

NOTE: Exiting IML.

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

NOTE: PROCEDURE IML used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

desireatem
Pyrite | Level 9

I have been reading since morning, got more than 70 hits but no one can help, Can you help me with this Rick? I made some changes to the code

NOTE: IML Ready

NOTE: Closing WORK.KMM_1

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

operation : + at line 7396 column 81

operands  : _TEM1002, _TEM1003

_TEM1002      1 row       7 cols    (numeric)

         0        20        40        60        80       100       120

_TEM1003      1 row      20 cols    (numeric)

statement : ASSIGN at line 7396 column 69

NOTE: Exiting IML.

NOTE: The data set WORK.GIB_1 has 140 observations and 11 variables.

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

NOTE: PROCEDURE IML used (Total process time):

      real time           0.11 seconds

      cpu time            0.06 seconds

proc iml;

use KMM_&p;

read all var{replicate time censored obs y  frequency survival1 } into DM;

/*read the 3 variables into matrix*/ /*have to print within DM*/

close;                                                                                     /*close the link between the dataset and IML*/

  survival1=DM[,7]; frequency=DM[,6]; y=DM[,5];obs =DM[,4]; censored=DM[,3]; time= DM[,2]; replicate = DM[,1];   /*Survivalival is second column*/  /*time is first column*/

*n = nrow(DM);

/*number of rows in the dataset = obs*/ /*THE N DOESNT NEED TO BE FIXED*/

                     /*Segment equals the number of consecutive patterns*/ /*J creates a matrix in IML , it creates a 20x1 matrix of 1s, the 3rd 1 is the value in matrix*/

segment = J(nrow(DM),1,1); *print segment;

u = unique(replicate);

do k = 1 to ncol(u);

BIG=J(140,11,-1) ;

byGroup = DM[loc(replicate=u),];

   *byIdx = loc(replicate=u); /* the UNIQUE-LOC trick */

  *byGroup = DM[byIdx,];           /* extract BY group */        /* extract BY group */

obs=byGroup[,6];y=byGroup[,5];freqency =byGroup[,4]; survival1 =byGroup[,3]; Censored= byGroup[,2]; time = byGroup[,1];

  do i = 2 to nrow(byGroup);

if ((Censored=1)=(Censored[i-1]=1)) then segment=segment[i-1];  /**/        /* coming up with unique segments for censored*****/;

else if ((Censored=1)=1-(Censored[i-1]=1)) then segment=segment[i-1]+1;

                     *print time survival1 censored frequency segment;                                

*print segment;

end;

    SurvivalM=J(nrow(survival1),1,1);

      do i = 1 to nrow(byGroup);

         if censored=1 then SurvivalM=survival1; else if censored=0 then SurvivalM=survival1;  /*****Create a 1 by N -matrix of Survival ****/;

          

end;

 

      *print SurvivalM;

    InverseC=J(nrow(survival1),1,1);

  do i = 1 to nrow(byGroup);

if censored=1 then InverseC=1/survival1; else if censored=0 then InverseC=0;  /*****survivalC is the imputed censored survival and set the real Survivalval to 1**/;

         end;

do i = 1 to ncol(frequency);

call symputx("j", i);

   m = num(symget("j"));

   m=1*m; print m;  %let mm=m;

end;

t=InverseC[(loc(InverseC^=0))]; print t;

tt=t(t); print tt;

Big[(u-1)*20+(1:20),1]=k;

Big[(u-1)*20+(1:20),2:(sum(censored=1)+1)]=survivalM*(tt);

end;

create GIB_&p from BIG[colname={COL1}];                               

append from BIG;

quit;

Wrong output:

IanWakeling
Barite | Level 11

The error message is correct, you have not assigned a value to the matrix byIidx.  You should have typed byIdx instead.

Rick_SAS
SAS Super FREQ

The error message says

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

which says that the matrix that you are using to index DM  is undefined.  You have a typo: it should be byIdx.

desireatem
Pyrite | Level 9

I made some changes, howver the problem with this code is where I mark bold, any corrections

NOTE: IML Ready

NOTE: Closing WORK.KMM_1

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

operation : + at line 7396 column 81

operands  : _TEM1002, _TEM1003

_TEM1002      1 row       7 cols    (numeric)

         0        20        40        60        80       100       120

_TEM1003      1 row      20 cols    (numeric)

statement : ASSIGN at line 7396 column 69

NOTE: Exiting IML.

NOTE: The data set WORK.GIB_1 has 140 observations and 11 variables.

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

NOTE: PROCEDURE IML used (Total process time):

      real time           0.11 seconds

      cpu time            0.06 seconds

proc iml;

use KMM_&p;

read all var{replicate time censored obs y  frequency survival1 } into DM;

/*read the 3 variables into matrix*/ /*have to print within DM*/

close;                                                                                     /*close the link between the dataset and IML*/

  survival1=DM[,7]; frequency=DM[,6]; y=DM[,5];obs =DM[,4]; censored=DM[,3]; time= DM[,2]; replicate = DM[,1];   /*Survivalival is second column*/  /*time is first column*/

*n = nrow(DM);

/*number of rows in the dataset = obs*/ /*THE N DOESNT NEED TO BE FIXED*/

                     /*Segment equals the number of consecutive patterns*/ /*J creates a matrix in IML , it creates a 20x1 matrix of 1s, the 3rd 1 is the value in matrix*/

segment = J(nrow(DM),1,1); *print segment;

u = unique(replicate);

do k = 1 to ncol(u);

BIG=J(140,11,-1) ;

byGroup = DM[loc(replicate=u),];

   *byIdx = loc(replicate=u); /* the UNIQUE-LOC trick */

  *byGroup = DM[byIdx,];           /* extract BY group */        /* extract BY group */

obs=byGroup[,6];y=byGroup[,5];freqency =byGroup[,4]; survival1 =byGroup[,3]; Censored= byGroup[,2]; time = byGroup[,1];

  do i = 2 to nrow(byGroup);

if ((Censored=1)=(Censored[i-1]=1)) then segment=segment[i-1];  /**/        /* coming up with unique segments for censored*****/;

else if ((Censored=1)=1-(Censored[i-1]=1)) then segment=segment[i-1]+1;

                     *print time survival1 censored frequency segment;                                 

*print segment;

end;

    SurvivalM=J(nrow(survival1),1,1);

      do i = 1 to nrow(byGroup);

         if censored=1 then SurvivalM=survival1; else if censored=0 then SurvivalM=survival1;  /*****Create a 1 by N -matrix of Survival ****/;

           

end;

  

      *print SurvivalM;

    InverseC=J(nrow(survival1),1,1);

  do i = 1 to nrow(byGroup);

if censored=1 then InverseC=1/survival1; else if censored=0 then InverseC=0;  /*****survivalC is the imputed censored survival and set the real Survivalval to 1**/;

         end;

do i = 1 to ncol(frequency);

call symputx("j", i);

   m = num(symget("j"));

   m=1*m; print m;  %let mm=m;

end;

t=InverseC[(loc(InverseC^=0))]; print t;

tt=t(t); print tt;

Big[(u-1)*20+(1:20),1]=k;

Big[(u-1)*20+(1:20),2:(sum(censored=1)+1)]=survivalM*(tt);

end;

create GIB_&p from BIG[colname={COL1}];                                

append from BIG;

quit;

IanWakeling
Barite | Level 11

Is the data the problem?  The vector 'replicate' copied from your input data set appears to have 7 unique values 1 to 7, so (u-1)*20 is a row vector with 7 values, which can not be added to the vector (1:20) as they do not conform.

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!

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
  • 10 replies
  • 2487 views
  • 9 likes
  • 3 in conversation