BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

I'm trying to fill fields per row as missing (currently some fields have zeros) for certain rows, where rep='N'.

All variables I'm replacing as missing either have a numerical value of zero or are missing.

But I'm getting an error:  Array subscript out of range at line 409 column 28.

data new;


set old;


if tot ge 10;


array vars var1 var2 var3 var4 var5 var6 var7;




if rep = 'N' then vars=.;


run;

3 REPLIES 3
Tom
Super User Tom
Super User

I am assuming that you want to assign missing to each of the variables when REP='N'.

if rep='N' then do over vars; vars=.; end;

or if you do not like the old style DO OVER then use an explicit index variable.

if rep='N' then do _n_=1 to dim(vars); vars(_n_)=. ; end;

ScottBass
Rhodochrosite | Level 12

Untested but should work:


data new;

   set old;

   if tot ge 10;

   if rep = 'N'  then call missing(of var:);  /* or call missing(of var1-var7);  read the doc on "of" keyword and variable lists */

run;


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
Sudhakar_A
Calcite | Level 5

if rep = 'N' then call missing(of var1-var7);

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2035 views
  • 0 likes
  • 4 in conversation