BookmarkSubscribeRSS Feed
Mabungane
Calcite | Level 5

Please help, how fix the error.

 

750 DATA;
751 SET WWW;
752 %macro dropout(data=,id=,time=,response=, out=);
753 %if %bquote(&data)=%then %let data=&syslast;
754 proc freq data=&data noprint;
755 tables &id /out=freqid;
756 tables &time /out=freqtime;
757 run;
758 proc iml;
759 reset noprint;
760 use freqid;
761 read all var {&id};
762 nsub = nrow(&id);
763 use freqtime;
764 read all var {&time};
765 ntime = nrow(&time);
766 time=&time;
767 use &data;
768 read all var {&id &time &response};
769 n = nrow(&response);
770 dropout =j(n,1,0);
771 ind = 1;
772 do while (ind <= nsub);
773 j=1;
774 if (&response[(ind-1)*ntime+j]=.)
775 then print"First measurement is missing";
776 if (&response[(ind-1)*ntime+j]^=.)then
777 do;
778 j=ntime;
779 do until (j=1);
780 if (&response[(ind-1)*ntime+j]=.)then
781 do;
782 dropout [(ind-1)*ntime+j]=1;
783 j=j-1;
784 end;
785 else j=1;
786 end;
787 end;
788 ind=ind+1;
789 end;
790 prev=j(n,1,1);
791 prev[2:n] = &response[1:n-1];
792 i=1;
793 do while(i<=n);
794 if &time[i]=time[1] then prev [i]=.;
795 i=i+1;
796 end;
797 create help var {&id &time &response dropout prev};
798 append;
799 quit;
800 data &out;
801 merge &data help;
802 run;
803 %mend;
804 %dropout(data=WWW,id=hh,time=time,response=wt,out=wgee1);

NOTE: There were 598 observations read from the data set WORK.WWW.
NOTE: The data set WORK.DATA12 has 598 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 598 observations read from the data set WORK.WWW.
NOTE: The data set WORK.FREQID has 188 observations and 3 variables.
NOTE: The data set WORK.FREQTIME has 6 observations and 3 variables.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds


NOTE: Writing HTML Body file: sashtml1.htm
NOTE: IML Ready
ERROR: (execution) Invalid subscript or subscript out of range.

operation : [ at line 1386 column 24
operands : wt, _TEM1003
wt 598 rows 1 col (numeric)

_TEM1003 1 row 1 col (numeric)

600

statement : IF at line 1386 column 11
NOTE: Exiting IML.
NOTE: The data set WORK.HELP has 598 observations and 5 variables.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
real time 0.28 seconds
cpu time 0.09 seconds

 


NOTE: There were 598 observations read from the data set WORK.WWW.
NOTE: There were 598 observations read from the data set WORK.HELP.
NOTE: The data set WORK.WGEE1 has 598 observations and 9 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


805 proc genmod data=wgee1 descending;
806 model wt = trt prev / pred dist=binomial; /*Here other baseline covariates can be added,
806! group=treatment*/
807 ods output obstats=pred;
808 run;

NOTE: PROC GENMOD is modeling the probability that wt='1'.
NOTE: The Pearson chi-square and deviance are not computed since the AGGREGATE option is not
specified.
NOTE: Algorithm converged.
NOTE: The scale parameter was held fixed.
NOTE: The data set WORK.PRED has 598 observations and 6 variables.
NOTE: PROCEDURE GENMOD used (Total process time):
real time 0.30 seconds
cpu time 0.15 seconds


809
810 data pred;
811 set pred;
812 keep observation pred;
813 run;

NOTE: There were 598 observations read from the data set WORK.PRED.
NOTE: The data set WORK.PRED has 598 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


814 data wgee1;
815 merge pred wgee1;
816 run;

NOTE: There were 598 observations read from the data set WORK.PRED.
NOTE: There were 598 observations read from the data set WORK.WGEE1.
NOTE: The data set WORK.WGEE1 has 598 observations and 11 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

2 REPLIES 2
Astounding
PROC Star

Confession:  I don't use IML.  On the other hand, this statement stands out:

 

do until (j=1);

 

At least in theory, it is possible that ntime could be a decimal fraction and therefore j could be a decimal fraction.  If that's the case, the UNTIL condition will never be met by substracting 1 from j.  It would be safer (and could conceivably fix the error condition) to use:

 

do until (j <= 1);

Ksharp
Super User

It looks like the error is coming from macro %dropout(data=WWW,id=hh,time=time,response=wt,out=wgee1);

And check the statement about WT .

 

operation : [ at line 1386 column 24
operands : wt, _TEM1003
wt 598 rows 1 col (numeric)

_TEM1003 1 row 1 col (numeric)

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!

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
  • 1119 views
  • 2 likes
  • 3 in conversation