LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 23 May 2003 14:37:23 +0200
Reply-To:   Braddock <gianluca.marchi@ITALY.ACNIELSEN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Braddock <gianluca.marchi@ITALY.ACNIELSEN.COM>
Organization:   Centro Servizi Interbusiness
Subject:   Do Loop

Hi all,

here we are to face another question about DO. I want to detect non-missing values in the first row of a matrix and then set the corresponding columns to missing for all the rows.

I start from this example:

data prova; a1=1;a2=.;a3=1;a4=1;a5=.;output; a1=.;a2=1;a3=.;a4=1;a5=.;output; a1=1;a2=.;a3=1;a4=1;a5=1;output; run;

So I have a 3x5 matrix. Non missing values for first row are at columns 1, 3 and 4. Now what I want is to assign missing values to all the first row variables and to A4, in the second row, and to A1, A3 and A4 in the third.

I have written the following code:

data pos; set prova; if _n_=1; array t (5) a1--a5; p1=0; p2=0; p3=0; p4=0; p5=0; array p (5) p1--p5; j=0; do i=1 to dim(t); if t(i)=1 then do; j+1 p(j)=i; end; end; keep p1--p5 j; run;

data prova1; merge prova pos; array a (*) a1--a5; array p (*) p1--p5; do i=1 to j; k=p(i); put p(i) k j a(k) i; a(k)=.; end; keep a1--a5; run;

I think you have dozen of better ideas about how to handle this problem (and any suggestion would be appreciated), however my question is about the error I get when SAS performs the last loop:

ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, or invalid.

I have no idea how to fix the problem, and you?

Thanks in advance Gianluca

Back to: Top of message | Previous page | Main SAS-L page