BookmarkSubscribeRSS Feed
SAShole
Pyrite | Level 9

Hi All,

     I have a data set with a named range that has a bunch of missing values. i want to fill in those missing values based off a condition of another variable (not in the named range). i know how to do this using array processing but was wondering if it is possible to do so in the way i've outline below.

Here is a fictitious data set to simplify my problem,

data have;

  input (x1-x3) (2.) some_number;

  cards;

. . . .

. . . 3

. . . 4

;

run;

data want;

  set have;

  if some_number > 0 then (x1-x3) = 0;

run;

2 REPLIES 2
data_null__
Jade | Level 19

data X2Zero;

   if 0 then set have(keep=x:);

   retain _all_ 0;

   output;

   stop;

   run;

data have;

   modify have;

   if some_number gt 0 then do point=1;

      set X2Zero point=point;

      replace;

      end;

   run;

proc print data=have;

   run;

Haikuo
Onyx | Level 15

No array().

data have;

infile cards truncover;

  input (x1-x3) (2.) some_number;

  cards;

. . . .

. . . 3

. . . 4

;

proc sql NOPRINT;

select cats('',name,'','=','0')  into :lst separated by '; ' from dictionary.columns where libname='WORK' AND MEMNAME='HAVE' and name ne 'some_number';    quit;

data want;

  set have;

  if some_number > 0 then do;

     &lst;

  end;

run;

proc print;run;

Haikuo

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 806 views
  • 6 likes
  • 3 in conversation