BookmarkSubscribeRSS Feed
NURAO
Obsidian | Level 7

Hi all. Basically im doing coding for boxplot for purpose outlier detection. I dont know what went wrong with my coding, no results no errors. I have tried FLOOR func to replace LOC, nothing happen still. code LEFT meaning, the data that clear from outlier as LOWFEN and UPPFEN are the fences to detect outlier. So how can i print the LEFT(data without outlier). my data contain 3 group. 

 

 

 

 

 

PROC IML;
RESET NONAME;


START BP(A) GLOBAL (NY,NCOL,RMEAN,VARX,N);
RMEAN=J(NCOL(NY),1,0);
Q1=RMEAN;
Q3=RMEAN;
RMAD=RMEAN;
MADN=RMEAN;
LOWFEN=RMEAN;
UPPFEN=RMEAN;
LEFT=RMEAN;
F=1;
M=0;

DO J=1 TO NCOL(NY);

SAMP=NY[J];
L=M+SAMP;
TEMP=A[F:L];

Q=quartile (TEMP);
Q1[J]=Q[2,1];
Q3[J]=Q[4,1];
RMAD[J]=MAD(TEMP,"MAD");
MADN[J]=MAD(TEMP,"NMAD");
LOWFEN[J]=Q1[J]-(1.44*MADN[J]);
UPPFEN[J]=Q3[J]+(1.44*MADN[J]);
LEFT[J]=TEMP[LOC(LOWFEN[J]<TEMP & TEMP<UPPFEN[J])];


M=L;
F=F+SAMP;

END;

PRINT LEFT;

 

FINISH;

********cubaan menggunakan data yg dijana*******;

NY = {11 11 11};
A = {5,8,7,3,9,4,3,29,5,6,7,
3,2,6,4,14,4,7,6,9,3,4,
9,9,8,7,10,11,27,12,15,17,16};

 

QUIT;

2 REPLIES 2
WarrenKuhfeld
Ammonite | Level 13

You did not print anything.  That is why nothing is printed.  You defined BP and two vectors, then you quit.  

Rick_SAS
SAS Super FREQ

First, you need to call the BP module before you quit:

RUN BP(A);

 

Second, in your module, you have the statement

LEFT[J]=TEMP[LOC(LOWFEN[J]<TEMP & TEMP<UPPFEN[J])];

The left-hand side of the assignment is a scalar. However, the right-hand side is *in general) a vector. You cannot assign a vector into a single element, so you will get 

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

which means that you are attempting a vector operation that doesn't make sense.

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 1038 views
  • 0 likes
  • 3 in conversation